summaryrefslogtreecommitdiff
path: root/Lib/test/test_exceptions.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_exceptions.py')
-rw-r--r--Lib/test/test_exceptions.py29
1 files changed, 23 insertions, 6 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index a7683ac946..91d85ef779 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -387,19 +387,36 @@ class ExceptionTests(unittest.TestCase):
def testChainingAttrs(self):
e = Exception()
- self.assertEqual(e.__context__, None)
- self.assertEqual(e.__cause__, None)
+ self.assertIsNone(e.__context__)
+ self.assertIs(e.__cause__, Ellipsis)
e = TypeError()
- self.assertEqual(e.__context__, None)
- self.assertEqual(e.__cause__, None)
+ self.assertIsNone(e.__context__)
+ self.assertIs(e.__cause__, Ellipsis)
class MyException(EnvironmentError):
pass
e = MyException()
- self.assertEqual(e.__context__, None)
- self.assertEqual(e.__cause__, None)
+ self.assertIsNone(e.__context__)
+ self.assertIs(e.__cause__, Ellipsis)
+
+ def testChainingDescriptors(self):
+ try:
+ raise Exception()
+ except Exception as exc:
+ e = exc
+
+ self.assertIsNone(e.__context__)
+ self.assertIs(e.__cause__, Ellipsis)
+
+ e.__context__ = NameError()
+ e.__cause__ = None
+ self.assertIsInstance(e.__context__, NameError)
+ self.assertIsNone(e.__cause__)
+
+ e.__cause__ = Ellipsis
+ self.assertIs(e.__cause__, Ellipsis)
def testKeywordArgs(self):
# test that builtin exception don't take keyword args,