summaryrefslogtreecommitdiff
path: root/Lib/test/test_exceptions.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2012-02-26 17:49:52 +1000
committerNick Coghlan <ncoghlan@gmail.com>2012-02-26 17:49:52 +1000
commitab7bf2143e67ddc1510413fa0d7f9c621adf22fa (patch)
tree62a24ed4f57e4db638ebde745bb83e2e09fc86e3 /Lib/test/test_exceptions.py
parentcda6b6d60d96e6f755da92deb5e4066839095791 (diff)
downloadcpython-git-ab7bf2143e67ddc1510413fa0d7f9c621adf22fa.tar.gz
Close issue #6210: Implement PEP 409
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,