[Python-checkins] gh-99553: add tests for ExceptionGroup wrapping (GH-99615)
miss-islington
webhook-mailer at python.org
Tue Apr 11 03:08:01 EDT 2023
https://github.com/python/cpython/commit/254494c4b9e8454ebf8583da6bf108dba4c20d44
commit: 254494c4b9e8454ebf8583da6bf108dba4c20d44
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2023-04-11T00:07:25-07:00
summary:
gh-99553: add tests for ExceptionGroup wrapping (GH-99615)
(cherry picked from commit 4cd1cc843aa4ae77a543cdd882da687300762e9d)
Co-authored-by: Zac Hatfield-Dodds <zac.hatfield.dodds at gmail.com>
files:
M Lib/test/test_exception_group.py
diff --git a/Lib/test/test_exception_group.py b/Lib/test/test_exception_group.py
index 7fb45462e20f..a61af067cb2a 100644
--- a/Lib/test/test_exception_group.py
+++ b/Lib/test/test_exception_group.py
@@ -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):
More information about the Python-checkins
mailing list