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

Method test_dropping_frames

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

Source from the content-addressed store, hash-verified

3463 [f'{__file__}:{some_inner.__code__.co_firstlineno + 1}'])
3464
3465 def test_dropping_frames(self):
3466 def f():
3467 1/0
3468
3469 def g():
3470 try:
3471 f()
3472 except Exception as e:
3473 return e.__traceback__
3474
3475 tb = g()
3476
3477 class Skip_G(traceback.StackSummary):
3478 def format_frame_summary(self, frame_summary, colorize=False):
3479 if frame_summary.name == 'g':
3480 return None
3481 return super().format_frame_summary(frame_summary)
3482
3483 stack = Skip_G.extract(
3484 traceback.walk_tb(tb)).format()
3485
3486 self.assertEqual(len(stack), 1)
3487 lno = f.__code__.co_firstlineno + 1
3488 self.assertEqual(
3489 stack[0],
3490 f' File "{__file__}", line {lno}, in f\n 1/0\n'
3491 )
3492
3493 def test_summary_should_show_carets(self):
3494 # See: https://github.com/python/cpython/issues/122353

Callers

nothing calls this directly

Calls 4

gFunction · 0.70
formatMethod · 0.45
extractMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected