summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_traceback.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-11-28 16:16:09 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-11-28 16:16:09 (GMT)
commitbcc63a86a943b03e7472109cbf6d7f962f6b0b5a (patch)
treec4d72e31f48fd3708ed6f133bcebb85b5ecda2ef /Lib/test/test_traceback.py
parent875ada4b0fefd2e399719d728073b681a04d31b4 (diff)
downloadcpython-bcc63a86a943b03e7472109cbf6d7f962f6b0b5a.zip
cpython-bcc63a86a943b03e7472109cbf6d7f962f6b0b5a.tar.gz
cpython-bcc63a86a943b03e7472109cbf6d7f962f6b0b5a.tar.bz2
Merged revisions 76573 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r76573 | antoine.pitrou | 2009-11-28 17:12:28 +0100 (sam., 28 nov. 2009) | 3 lines Issue #4486: When an exception has an explicit cause, do not print its implicit context too. ........
Diffstat (limited to 'Lib/test/test_traceback.py')
-rw-r--r--Lib/test/test_traceback.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index 2145710..17413db 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -253,6 +253,26 @@ class BaseExceptionReportingTests:
self.check_zero_div(blocks[0])
self.assertTrue('inner_raise() # Marker' in blocks[2])
+ def test_cause_and_context(self):
+ # When both a cause and a context are set, only the cause should be
+ # displayed and the context should be muted.
+ def inner_raise():
+ try:
+ self.zero_div()
+ except ZeroDivisionError as _e:
+ e = _e
+ try:
+ xyzzy
+ except NameError:
+ raise KeyError from e
+ def outer_raise():
+ inner_raise() # Marker
+ blocks = boundaries.split(self.get_report(outer_raise))
+ self.assertEquals(len(blocks), 3)
+ self.assertEquals(blocks[1], cause_message)
+ self.check_zero_div(blocks[0])
+ self.assert_('inner_raise() # Marker' in blocks[2])
+
def test_cause_recursive(self):
def inner_raise():
try: