Skip to content

Commit 4cd1cc8

Browse files
authored
gh-99553: add tests for ExceptionGroup wrapping (#99615)
1 parent 280bd53 commit 4cd1cc8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Lib/test/test_exception_group.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,20 @@ class MyEG(BaseExceptionGroup, ValueError):
102102
with self.assertRaisesRegex(TypeError, msg):
103103
MyEG("eg", [ValueError(12), KeyboardInterrupt(42)])
104104

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

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

0 commit comments

Comments
 (0)