Skip to content

Commit

Permalink
gh-99553: add tests for ExceptionGroup wrapping (GH-99615)
Browse files Browse the repository at this point in the history
(cherry picked from commit 4cd1cc8)

Co-authored-by: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>
  • Loading branch information
miss-islington and Zac-HD authored Apr 11, 2023
1 parent a836d79 commit 254494c
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 @@ -103,6 +103,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 254494c

Please sign in to comment.