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

Method test_formatting

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

Source from the content-addressed store, hash-verified

4971
4972class ExceptionTest(BaseTest):
4973 def test_formatting(self):
4974 r = self.root_logger
4975 h = RecordingHandler()
4976 r.addHandler(h)
4977 try:
4978 raise RuntimeError('deliberate mistake')
4979 except RuntimeError:
4980 logging.exception('failed', stack_info=True)
4981 r.removeHandler(h)
4982 h.close()
4983 r = h.records[0]
4984 self.assertStartsWith(r.exc_text,
4985 'Traceback (most recent call last):\n')
4986 self.assertEndsWith(r.exc_text,
4987 '\nRuntimeError: deliberate mistake')
4988 self.assertStartsWith(r.stack_info,
4989 'Stack (most recent call last):\n')
4990 self.assertEndsWith(r.stack_info,
4991 "logging.exception('failed', stack_info=True)")
4992
4993
4994class LastResortTest(BaseTest):

Callers

nothing calls this directly

Calls 7

RecordingHandlerClass · 0.85
addHandlerMethod · 0.80
removeHandlerMethod · 0.80
assertStartsWithMethod · 0.80
assertEndsWithMethod · 0.80
exceptionMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected