mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-105292: Add option to make traceback.TracebackException.format_exception_only recurse into exception groups (#105294)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
parent
92022d8416
commit
f4d8e10d0d
5 changed files with 48 additions and 13 deletions
|
@ -2792,6 +2792,20 @@ class TestTracebackException_ExceptionGroups(unittest.TestCase):
|
|||
|
||||
self.assertEqual(formatted, expected)
|
||||
|
||||
def test_exception_group_format_exception_onlyi_recursive(self):
|
||||
teg = traceback.TracebackException.from_exception(self.eg)
|
||||
formatted = ''.join(teg.format_exception_only(show_group=True)).split('\n')
|
||||
expected = [
|
||||
'ExceptionGroup: eg2 (2 sub-exceptions)',
|
||||
' ExceptionGroup: eg1 (2 sub-exceptions)',
|
||||
' ZeroDivisionError: division by zero',
|
||||
' ValueError: 42',
|
||||
' ValueError: 24',
|
||||
''
|
||||
]
|
||||
|
||||
self.assertEqual(formatted, expected)
|
||||
|
||||
def test_exception_group_format(self):
|
||||
teg = traceback.TracebackException.from_exception(self.eg)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue