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

Method test_nested_inherited

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

Source from the content-addressed store, hash-verified

265 ])
266
267 def test_nested_inherited(self):
268 # Logging levels in a nested namespace, inherited from parent loggers.
269 m = self.next_message
270
271 INF = logging.getLogger("INF")
272 INF.setLevel(logging.INFO)
273 INF_ERR = logging.getLogger("INF.ERR")
274 INF_ERR.setLevel(logging.ERROR)
275 INF_UNDEF = logging.getLogger("INF.UNDEF")
276 INF_ERR_UNDEF = logging.getLogger("INF.ERR.UNDEF")
277 UNDEF = logging.getLogger("UNDEF")
278
279 # These should log.
280 INF_UNDEF.log(logging.CRITICAL, m())
281 INF_UNDEF.error(m())
282 INF_UNDEF.warning(m())
283 INF_UNDEF.info(m())
284 INF_ERR_UNDEF.log(logging.CRITICAL, m())
285 INF_ERR_UNDEF.error(m())
286
287 # These should not log.
288 INF_UNDEF.debug(m())
289 INF_ERR_UNDEF.warning(m())
290 INF_ERR_UNDEF.info(m())
291 INF_ERR_UNDEF.debug(m())
292
293 self.assert_log_lines([
294 ('INF.UNDEF', 'CRITICAL', '1'),
295 ('INF.UNDEF', 'ERROR', '2'),
296 ('INF.UNDEF', 'WARNING', '3'),
297 ('INF.UNDEF', 'INFO', '4'),
298 ('INF.ERR.UNDEF', 'CRITICAL', '5'),
299 ('INF.ERR.UNDEF', 'ERROR', '6'),
300 ])
301
302 def test_nested_with_virtual_parent(self):
303 # Logging levels when some parent does not exist yet.

Callers

nothing calls this directly

Calls 9

getLoggerMethod · 0.80
assert_log_linesMethod · 0.80
mFunction · 0.50
setLevelMethod · 0.45
logMethod · 0.45
errorMethod · 0.45
warningMethod · 0.45
infoMethod · 0.45
debugMethod · 0.45

Tested by

no test coverage detected