Skip to content

Commit f5acfef

Browse files
committed
Test custom sequence's ExceptionGroup repr
1 parent e9fec3d commit f5acfef

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Lib/test/test_exception_group.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import collections.abc
1+
import collections
22
import types
33
import unittest
44
from test.support import skip_emscripten_stack_overflow, skip_wasi_stack_overflow, exceeds_recursion_limit
@@ -212,9 +212,19 @@ class MyEG(ExceptionGroup):
212212
excs = (ValueError(1), KeyboardInterrupt(2))
213213
eg = BaseExceptionGroup('test', excs)
214214

215-
# Ensure that other, immutable, sequences still work fine.
215+
# Ensure that immutable sequences still work fine.
216216
self.assertEqual(repr(eg), "BaseExceptionGroup('test', (ValueError(1), KeyboardInterrupt(2)))")
217217

218+
# Test non-standard custom sequences.
219+
excs = collections.deque([ValueError(1), TypeError(2)])
220+
eg = ExceptionGroup('test', excs)
221+
222+
self.assertEqual(repr(eg), "ExceptionGroup('test', (ValueError(1), TypeError(2)))")
223+
excs.clear()
224+
225+
# Ensure that clearing the exceptions sequence doesn't change the repr.
226+
self.assertEqual(repr(eg), "ExceptionGroup('test', (ValueError(1), TypeError(2)))")
227+
218228

219229
def create_simple_eg():
220230
excs = []

0 commit comments

Comments
 (0)