mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-112217: Add check to call result for do_raise()
where cause is a type. (#112216)
This commit is contained in:
parent
4dcfd02bed
commit
8f71b349de
3 changed files with 22 additions and 0 deletions
|
@ -185,6 +185,20 @@ class TestCause(unittest.TestCase):
|
|||
else:
|
||||
self.fail("No exception raised")
|
||||
|
||||
def test_class_cause_nonexception_result(self):
|
||||
class ConstructsNone(BaseException):
|
||||
@classmethod
|
||||
def __new__(*args, **kwargs):
|
||||
return None
|
||||
try:
|
||||
raise IndexError from ConstructsNone
|
||||
except TypeError as e:
|
||||
self.assertIn("should have returned an instance of BaseException", str(e))
|
||||
except IndexError:
|
||||
self.fail("Wrong kind of exception raised")
|
||||
else:
|
||||
self.fail("No exception raised")
|
||||
|
||||
def test_instance_cause(self):
|
||||
cause = KeyError()
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue