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

Method test_context

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

Source from the content-addressed store, hash-verified

3625 self.assertEqual(str(exc_obj), str(exc))
3626
3627 def test_context(self):
3628 try:
3629 try:
3630 1/0
3631 finally:
3632 exc = sys.exception()
3633 exc_context = traceback.TracebackException.from_exception(exc)
3634 raise Exception("uh oh")
3635 except Exception as e:
3636 exc_obj = e
3637 exc = traceback.TracebackException.from_exception(e)
3638 expected_stack = traceback.StackSummary.extract(
3639 traceback.walk_tb(e.__traceback__))
3640 self.assertEqual(None, exc.__cause__)
3641 self.assertEqual(exc_context, exc.__context__)
3642 self.assertEqual(False, exc.__suppress_context__)
3643 self.assertEqual(expected_stack, exc.stack)
3644 with self.assertWarns(DeprecationWarning):
3645 self.assertEqual(type(exc_obj), exc.exc_type)
3646 self.assertEqual(type(exc_obj).__name__, exc.exc_type_str)
3647 self.assertEqual(str(exc_obj), str(exc))
3648
3649 def test_long_context_chain(self):
3650 def f():

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