Skip to content

Instantly share code, notes, and snippets.

@pelarejo
Last active July 10, 2019 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pelarejo/23b9bf200c74ee96d86b799ef0b75aad to your computer and use it in GitHub Desktop.
Save pelarejo/23b9bf200c74ee96d86b799ef0b75aad to your computer and use it in GitHub Desktop.
PyTest UnitTest Logs
import logging
class LogTestCase(TestCase):
@pytest.fixture(autouse=True)
def inject_fixtures(self, caplog):
self._caplog = caplog
def test_loggin(self):
# do stuff
with self._caplog.at_level(logging.INFO):
assert self._caplog.records[0].message == 'test'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment