mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Fix refleaks exposed by test_raise.
This commit is contained in:
parent
1963ad3126
commit
1966f1c98f
3 changed files with 31 additions and 3 deletions
|
@ -37,6 +37,18 @@ class TestRaise(unittest.TestCase):
|
|||
else:
|
||||
self.fail("No exception raised")
|
||||
|
||||
def test_erroneous_exception(self):
|
||||
class MyException(Exception):
|
||||
def __init__(self):
|
||||
raise RuntimeError()
|
||||
|
||||
try:
|
||||
raise MyException
|
||||
except RuntimeError:
|
||||
pass
|
||||
else:
|
||||
self.fail("No exception raised")
|
||||
|
||||
|
||||
class TestCause(unittest.TestCase):
|
||||
def test_invalid_cause(self):
|
||||
|
@ -64,6 +76,18 @@ class TestCause(unittest.TestCase):
|
|||
else:
|
||||
self.fail("No exception raised")
|
||||
|
||||
def test_erroneous_cause(self):
|
||||
class MyException(Exception):
|
||||
def __init__(self):
|
||||
raise RuntimeError()
|
||||
|
||||
try:
|
||||
raise IndexError from MyException
|
||||
except RuntimeError:
|
||||
pass
|
||||
else:
|
||||
self.fail("No exception raised")
|
||||
|
||||
|
||||
class TestTraceback(unittest.TestCase):
|
||||
def test_sets_traceback(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue