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

Method test_long_context_chain

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

Source from the content-addressed store, hash-verified

3647 self.assertEqual(str(exc_obj), str(exc))
3648
3649 def test_long_context_chain(self):
3650 def f():
3651 try:
3652 1/0
3653 except ZeroDivisionError:
3654 f()
3655
3656 try:
3657 f()
3658 except RecursionError as e:
3659 exc_obj = e
3660 else:
3661 self.fail("Exception not raised")
3662
3663 te = traceback.TracebackException.from_exception(exc_obj)
3664 res = list(te.format())
3665
3666 # many ZeroDiv errors followed by the RecursionError
3667 self.assertGreater(len(res), sys.getrecursionlimit())
3668 self.assertGreater(
3669 len([l for l in res if 'ZeroDivisionError:' in l]),
3670 sys.getrecursionlimit() * 0.5)
3671 self.assertIn(
3672 "RecursionError: maximum recursion depth exceeded", res[-1])
3673
3674 def test_compact_with_cause(self):
3675 try:

Callers

nothing calls this directly

Calls 7

listClass · 0.85
from_exceptionMethod · 0.80
assertGreaterMethod · 0.80
assertInMethod · 0.80
fFunction · 0.70
failMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected