mirror of https://github.com/python/cpython.git
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:
parent
a836d79111
commit
254494c4b9
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue