MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / test_lines_with_yield

Function test_lines_with_yield

tests_python/test_sys_monitoring.py:254–294  ·  view source on GitHub ↗
(with_monitoring)

Source from the content-addressed store, hash-verified

252
253
254def test_lines_with_yield(with_monitoring):
255 def _start_method(code, offset):
256 if "test_sys_monitoring.py" in code.co_filename:
257 print("start ", code.co_name)
258 monitor.set_local_events(DEBUGGER_ID, code, monitor.events.LINE | monitor.events.JUMP | monitor.events.PY_YIELD)
259
260 def _on_line(code, line):
261 if "test_sys_monitoring.py" in code.co_filename:
262 print("on line", code.co_name, line - code.co_firstlineno)
263
264 def _on_jump(code, from_offset, to_offset):
265 if "test_sys_monitoring.py" in code.co_filename:
266 frame = sys._getframe().f_back
267 print("on jump", code.co_name, frame.f_lineno - code.co_firstlineno)
268
269 def _yield_method(code, offset, retval):
270 if "test_sys_monitoring.py" in code.co_filename:
271 frame = sys._getframe().f_back
272 print("on yield", code.co_name, frame.f_lineno - code.co_firstlineno)
273
274 monitor.set_events(DEBUGGER_ID, monitor.events.PY_START | monitor.events.PY_RESUME)
275
276 monitor.register_callback(DEBUGGER_ID, monitor.events.PY_START, _start_method)
277 monitor.register_callback(DEBUGGER_ID, monitor.events.PY_RESUME, _start_method)
278 monitor.register_callback(DEBUGGER_ID, monitor.events.PY_YIELD, _yield_method)
279 monitor.register_callback(DEBUGGER_ID, monitor.events.LINE, _on_line)
280 monitor.register_callback(DEBUGGER_ID, monitor.events.JUMP, _on_jump)
281
282 def method():
283 a = [1, 2, 3, 4, 5, 6] # line 1
284
285 # line 3
286 def b(): # line 4
287 yield from [j for j in a if j % 2 == 0] # line 5
288
289 # line 7
290 for j in b(): # line 8
291 print(j) # line 9
292
293 method()
294 monitor.set_events(DEBUGGER_ID, 0)

Callers

nothing calls this directly

Calls 1

methodFunction · 0.70

Tested by

no test coverage detected