Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-99553: add tests for ExceptionGroup wrapping (GH-99615)
(cherry picked from commit 4cd1cc8)

Co-authored-by: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>
  • Loading branch information
Zac-HD authored and miss-islington committed Apr 11, 2023
commit 0fd85aa5d27a7c1f6d632dabaa33be7b191f678e
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