Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_adapt_level(self):
self.assertEqual(
av.logging.adapt_level(av.logging.ERROR),
logging.ERROR
)
self.assertEqual(
av.logging.adapt_level(av.logging.WARNING),
logging.WARNING
)
self.assertEqual(
av.logging.adapt_level((av.logging.WARNING + av.logging.ERROR) // 2),
logging.WARNING
)
def test_adapt_level(self):
self.assertEqual(
av.logging.adapt_level(av.logging.ERROR),
logging.ERROR
)
self.assertEqual(
av.logging.adapt_level(av.logging.WARNING),
logging.WARNING
)
self.assertEqual(
av.logging.adapt_level((av.logging.WARNING + av.logging.ERROR) // 2),
logging.WARNING
)
def test_repeats(self):
with av.logging.Capture() as logs:
do_log('foo')
do_log('foo')
do_log('bar')
do_log('bar')
do_log('bar')
do_log('baz')
logs = [l for l in logs if l[1] == 'test']
self.assertEqual(logs, [
(av.logging.INFO, 'test', 'foo'),
(av.logging.INFO, 'test', 'foo'),
(av.logging.INFO, 'test', 'bar'),
(av.logging.INFO, 'test', 'bar (repeated 2 more times)'),
(av.logging.INFO, 'test', 'baz'),
def do_log(message):
av.logging.log(av.logging.INFO, 'test', message)