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

Method test_jump_to_firstlineno

Lib/test/test_sys_settrace.py:2811–2828  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2809 self.run_test(f, 2, 1007, [0], warning=(RuntimeWarning, self.unbound_locals))
2810
2811 def test_jump_to_firstlineno(self):
2812 # This tests that PDB can jump back to the first line in a
2813 # file. See issue #1689458. It can only be triggered in a
2814 # function call if the function is defined on a single line.
2815 code = compile("""
2816# Comments don't count.
2817output.append(2) # firstlineno is here.
2818output.append(3)
2819output.append(4)
2820""", "<fake module>", "exec")
2821 class fake_function:
2822 __code__ = code
2823 tracer = JumpTracer(fake_function, 4, 1)
2824 sys.settrace(tracer.trace)
2825 namespace = {"output": []}
2826 exec(code, namespace)
2827 sys.settrace(None)
2828 self.compare_jump_output([2, 3, 2, 3, 4], namespace["output"])
2829
2830 @jump_test(2, 3, [1], event='call', error=(ValueError, "can't jump from"
2831 " the 'call' trace event of a new frame"))

Callers

nothing calls this directly

Calls 3

compare_jump_outputMethod · 0.95
JumpTracerClass · 0.85
compileFunction · 0.50

Tested by

no test coverage detected