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

(cherry picked from commit 4cd1cc843a)

Co-authored-by: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>
This commit is contained in:
Miss Islington (bot) 2023-04-11 00:07:25 -07:00 committed by GitHub
parent a836d79111
commit 254494c4b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

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