gh-99553: add tests for ExceptionGroup wrapping (#99615)

This commit is contained in:
Zac Hatfield-Dodds 2023-04-10 23:44:53 -07:00 committed by GitHub
parent 280bd536b5
commit 4cd1cc843a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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):