Last active
July 10, 2019 16:08
-
-
Save pelarejo/23b9bf200c74ee96d86b799ef0b75aad to your computer and use it in GitHub Desktop.
PyTest UnitTest Logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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