MCPcopy Index your code
hub / github.com/python/cpython / checkAssertLogsPerLogger

Method checkAssertLogsPerLogger

Lib/test/test_unittest/test_case.py:1865–1877  ·  view source on GitHub ↗
(self, logger)

Source from the content-addressed store, hash-verified

1863 self.checkAssertLogsPerLevel('ERROR')
1864
1865 def checkAssertLogsPerLogger(self, logger):
1866 # Check per-logger filtering
1867 with self.assertNoStderr():
1868 with self.assertLogs(level='DEBUG') as outer_cm:
1869 with self.assertLogs(logger, level='DEBUG') as cm:
1870 log_foo.info("1")
1871 log_foobar.debug("2")
1872 log_quux.warning("3")
1873 self.assertEqual(cm.output, ["INFO:foo:1", "DEBUG:foo.bar:2"])
1874 self.assertLogRecords(cm.records,
1875 [{'name': 'foo'}, {'name': 'foo.bar'}])
1876 # The outer catchall caught the quux log
1877 self.assertEqual(outer_cm.output, ["WARNING:quux:3"])
1878
1879 def testAssertLogsPerLogger(self):
1880 self.checkAssertLogsPerLogger(logging.getLogger('foo'))

Callers 1

Calls 7

assertNoStderrMethod · 0.95
assertLogRecordsMethod · 0.95
assertLogsMethod · 0.80
infoMethod · 0.45
debugMethod · 0.45
warningMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected