Fix refleaks exposed by test_raise.

This commit is contained in:
Collin Winter 2007-09-01 20:26:44 +00:00
parent 1963ad3126
commit 1966f1c98f
3 changed files with 31 additions and 3 deletions

View file

@ -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):