summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test')
-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):