summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_raise.py
diff options
context:
space:
mode:
authorCollin Winter <collinw@gmail.com>2007-09-01 20:26:44 (GMT)
committerCollin Winter <collinw@gmail.com>2007-09-01 20:26:44 (GMT)
commit1966f1c98f32c482b16f1a9c1a36fc8e0628486b (patch)
tree32712f50c111e5cc456278f3ce868f36ee54f57d /Lib/test/test_raise.py
parent1963ad3126806672cf49ded8f524f105dcc72d33 (diff)
downloadcpython-1966f1c98f32c482b16f1a9c1a36fc8e0628486b.zip
cpython-1966f1c98f32c482b16f1a9c1a36fc8e0628486b.tar.gz
cpython-1966f1c98f32c482b16f1a9c1a36fc8e0628486b.tar.bz2
Fix refleaks exposed by test_raise.
Diffstat (limited to 'Lib/test/test_raise.py')
-rw-r--r--Lib/test/test_raise.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_raise.py b/Lib/test/test_raise.py
index 0e19972..27a5cbc 100644
--- a/Lib/test/test_raise.py
+++ b/Lib/test/test_raise.py
@@ -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):