Skip to content

Commit 254494c

Browse files
gh-99553: add tests for ExceptionGroup wrapping (GH-99615)
(cherry picked from commit 4cd1cc8) Co-authored-by: Zac Hatfield-Dodds <[email protected]>
1 parent a836d79 commit 254494c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Lib/test/test_exception_group.py

+14
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,20 @@ class MyEG(BaseExceptionGroup, ValueError):
103103
with self.assertRaisesRegex(TypeError, msg):
104104
MyEG("eg", [ValueError(12), KeyboardInterrupt(42)])
105105

106+
def test_EG_and_specific_subclass_can_wrap_any_nonbase_exception(self):
107+
class MyEG(ExceptionGroup, ValueError):
108+
pass
109+
110+
# The restriction is specific to Exception, not "the other base class"
111+
MyEG("eg", [ValueError(12), Exception()])
112+
113+
def test_BEG_and_specific_subclass_can_wrap_any_nonbase_exception(self):
114+
class MyEG(BaseExceptionGroup, ValueError):
115+
pass
116+
117+
# The restriction is specific to Exception, not "the other base class"
118+
MyEG("eg", [ValueError(12), Exception()])
119+
106120

107121
def test_BEG_subclass_wraps_anything(self):
108122
class MyBEG(BaseExceptionGroup):

0 commit comments

Comments
 (0)