MCPcopy Create free account
hub / github.com/python/cpython / test_warnings_no_handlers

Method test_warnings_no_handlers

Lib/test/test_logging.py:2364–2375  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2362 "dummy.py:42: UserWarning: Explicit\n Dummy line\n")
2363
2364 def test_warnings_no_handlers(self):
2365 with warnings.catch_warnings():
2366 logging.captureWarnings(True)
2367 self.addCleanup(logging.captureWarnings, False)
2368
2369 # confirm our assumption: no loggers are set
2370 logger = logging.getLogger("py.warnings")
2371 self.assertEqual(logger.handlers, [])
2372
2373 warnings.showwarning("Explicit", UserWarning, "dummy.py", 42)
2374 self.assertEqual(len(logger.handlers), 1)
2375 self.assertIsInstance(logger.handlers[0], logging.NullHandler)
2376
2377
2378def formatFunc(format, datefmt=None):

Callers

nothing calls this directly

Calls 5

addCleanupMethod · 0.80
getLoggerMethod · 0.80
showwarningMethod · 0.80
assertIsInstanceMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected