MCPcopy Index your code
hub / github.com/python/cpython / test_cause

Method test_cause

Lib/test/test_traceback.py:3603–3625  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3601 self.assertEqual(str(exc_obj), str(exc))
3602
3603 def test_cause(self):
3604 try:
3605 try:
3606 1/0
3607 finally:
3608 exc = sys.exception()
3609 exc_context = traceback.TracebackException.from_exception(exc)
3610 cause = Exception("cause")
3611 raise Exception("uh oh") from cause
3612 except Exception as e:
3613 exc_obj = e
3614 exc = traceback.TracebackException.from_exception(e)
3615 expected_stack = traceback.StackSummary.extract(
3616 traceback.walk_tb(e.__traceback__))
3617 exc_cause = traceback.TracebackException(Exception, cause, None)
3618 self.assertEqual(exc_cause, exc.__cause__)
3619 self.assertEqual(exc_context, exc.__context__)
3620 self.assertEqual(True, exc.__suppress_context__)
3621 self.assertEqual(expected_stack, exc.stack)
3622 with self.assertWarns(DeprecationWarning):
3623 self.assertEqual(type(exc_obj), exc.exc_type)
3624 self.assertEqual(type(exc_obj).__name__, exc.exc_type_str)
3625 self.assertEqual(str(exc_obj), str(exc))
3626
3627 def test_context(self):
3628 try:

Callers

nothing calls this directly

Calls 6

strFunction · 0.85
from_exceptionMethod · 0.80
assertWarnsMethod · 0.80
exceptionMethod · 0.45
extractMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected