logging doesnt print python code example
Example: testing logging python
# can be done by using unittest's assertLogs
from unittest import TestCase
class MyTest(TestCase):
def test_logs(self):
with self.assertLogs('foo', level='INFO') as cm:
logging.getLogger('foo').info('first message')
logging.getLogger('foo.bar').error('second message')
self.assertEqual(cm.output, ['INFO:foo:first message',
'ERROR:foo.bar:second message'])