mirror of
https://github.com/python/cpython
synced 2024-10-14 17:56:08 +00:00
gh-99553: add tests for ExceptionGroup wrapping (#99615)
This commit is contained in:
parent
280bd536b5
commit
4cd1cc843a
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue