Answers for "logging tests in python"

0

logging python

logging.basicConfig(filename='example.log', filemode='w', level=logging.DEBUG)
Posted by: Guest on June-04-2021
0

python logging levels

Logging Levels

CRITICAL
ERROR
WARNING
INFO
DEBUG
NOTSET
Posted by: Guest on November-22-2021
0

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'])
Posted by: Guest on January-15-2021

Python Answers by Framework

Browse Popular Code Answers by Language