mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Closes #20537: logging methods now accept an exception instance as well as a Boolean value or exception tuple. Thanks to Yury Selivanov for the patch.
This commit is contained in:
parent
4ff91eb5e3
commit
02a8f9e9ac
4 changed files with 34 additions and 14 deletions
|
@ -3712,6 +3712,19 @@ class LoggerAdapterTest(unittest.TestCase):
|
|||
self.assertEqual(record.exc_info,
|
||||
(exc.__class__, exc, exc.__traceback__))
|
||||
|
||||
def test_exception_excinfo(self):
|
||||
try:
|
||||
1 / 0
|
||||
except ZeroDivisionError as e:
|
||||
exc = e
|
||||
|
||||
self.adapter.exception('exc_info test', exc_info=exc)
|
||||
|
||||
self.assertEqual(len(self.recording.records), 1)
|
||||
record = self.recording.records[0]
|
||||
self.assertEqual(record.exc_info,
|
||||
(exc.__class__, exc, exc.__traceback__))
|
||||
|
||||
def test_critical(self):
|
||||
msg = 'critical test! %r'
|
||||
self.adapter.critical(msg, self.recording)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue