]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-99553: add tests for ExceptionGroup wrapping (#99615)
authorZac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>
Tue, 11 Apr 2023 06:44:53 +0000 (23:44 -0700)
committerGitHub <noreply@github.com>
Tue, 11 Apr 2023 06:44:53 +0000 (23:44 -0700)
Lib/test/test_exception_group.py

index b11524e778e66557d56560db3c95e04a117a6099..fa159a76ec1aff6604afe509cf3a8922d1fd803e 100644 (file)
@@ -102,6 +102,20 @@ class InstanceCreation(unittest.TestCase):
         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):