diff options
author | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-02-07 18:44:12 +0000 |
---|---|---|
committer | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-02-07 18:44:12 +0000 |
commit | 2bd52dcccbd38908ae2a3b3bdceb3b04d6b16c81 (patch) | |
tree | 089ff2404ebb4b86054f3dda2b0396b9c99f8038 /Lib/test/test_unittest.py | |
parent | a4f46e129294c686ef1effdd89c459bd9a624e6d (diff) | |
download | cpython-git-2bd52dcccbd38908ae2a3b3bdceb3b04d6b16c81.tar.gz |
assertRaises as context manager now allows you to access exception as documented
Diffstat (limited to 'Lib/test/test_unittest.py')
-rw-r--r-- | Lib/test/test_unittest.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/test/test_unittest.py b/Lib/test/test_unittest.py index ab043822da..04a7322b23 100644 --- a/Lib/test/test_unittest.py +++ b/Lib/test/test_unittest.py @@ -3059,8 +3059,13 @@ class Test_Assertions(TestCase): pass else: self.fail("assertRaises() didn't let exception pass through") - with self.assertRaises(KeyError): - raise KeyError + with self.assertRaises(KeyError) as cm: + try: + raise KeyError + except Exception, e: + raise + self.assertIs(cm.exception, e) + with self.assertRaises(KeyError): raise KeyError("key") try: |