Skip to content

Commit

Permalink
gh-99553: add tests for ExceptionGroup wrapping (#99615)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD authored Apr 11, 2023
1 parent 280bd53 commit 4cd1cc8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Lib/test/test_exception_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@ class MyEG(BaseExceptionGroup, ValueError):
with self.assertRaisesRegex(TypeError, msg):
MyEG("eg", [ValueError(12), KeyboardInterrupt(42)])

def test_EG_and_specific_subclass_can_wrap_any_nonbase_exception(self):
class MyEG(ExceptionGroup, ValueError):
pass

# The restriction is specific to Exception, not "the other base class"
MyEG("eg", [ValueError(12), Exception()])

def test_BEG_and_specific_subclass_can_wrap_any_nonbase_exception(self):
class MyEG(BaseExceptionGroup, ValueError):
pass

# The restriction is specific to Exception, not "the other base class"
MyEG("eg", [ValueError(12), Exception()])


def test_BEG_subclass_wraps_anything(self):
class MyBEG(BaseExceptionGroup):
Expand Down

0 comments on commit 4cd1cc8

Please sign in to comment.