Index: Lib/unittest/case.py =================================================================== --- Lib/unittest/case.py (revision 84794) +++ Lib/unittest/case.py (working copy) @@ -107,6 +107,12 @@ expected_regexp = re.compile(expected_regexp) self.expected_regexp = expected_regexp +def _clear_traceback(exc_value): + if isinstance(exc_value.__cause__, BaseException): + exc_value.__cause__ = _clear_traceback(exc_value.__cause__) + if isinstance(exc_value.__context__, BaseException): + exc_value.__context__ = _clear_traceback(exc_value.__context__) + return exc_value.with_traceback(None) class _AssertRaisesContext(_AssertRaisesBaseContext): """A context manager used to implement TestCase.assertRaises* methods.""" @@ -130,7 +136,7 @@ # let unexpected exceptions pass through return False # store exception, without traceback, for later retrieval - self.exception = exc_value.with_traceback(None) + self.exception = _clear_traceback(exc_value) if self.expected_regexp is None: return True