(pyfile, run, target)
| 9 | |
| 10 | |
| 11 | def test_set_next_statement(pyfile, run, target): |
| 12 | @pyfile |
| 13 | def code_to_debug(): |
| 14 | import debuggee |
| 15 | |
| 16 | debuggee.setup() |
| 17 | |
| 18 | def func(): |
| 19 | print(1) # @inner1 |
| 20 | print(2) # @inner2 |
| 21 | |
| 22 | print(3) # @outer3 |
| 23 | func() |
| 24 | |
| 25 | line_numbers = code_to_debug.lines |
| 26 | |
| 27 | with debug.Session() as session: |
| 28 | with run(session, target(code_to_debug)): |
| 29 | session.set_breakpoints(code_to_debug, ["inner1"]) |
| 30 | |
| 31 | stop = session.wait_for_stop( |
| 32 | expected_frames=[some.dap.frame(code_to_debug, "inner1")] |
| 33 | ) |
| 34 | |
| 35 | targets = session.request( |
| 36 | "gotoTargets", |
| 37 | {"source": {"path": code_to_debug}, "line": line_numbers["outer3"]}, |
| 38 | )["targets"] |
| 39 | assert targets == [ |
| 40 | {"id": some.number, "label": some.str, "line": line_numbers["outer3"]} |
| 41 | ] |
| 42 | outer3_target = targets[0]["id"] |
| 43 | |
| 44 | with pytest.raises(Exception): |
| 45 | session.request( |
| 46 | "goto", {"threadId": stop.thread_id, "targetId": outer3_target} |
| 47 | ) |
| 48 | |
| 49 | targets = session.request( |
| 50 | "gotoTargets", |
| 51 | {"source": {"path": code_to_debug}, "line": line_numbers["inner2"]}, |
| 52 | )["targets"] |
| 53 | assert targets == [ |
| 54 | {"id": some.number, "label": some.str, "line": line_numbers["inner2"]} |
| 55 | ] |
| 56 | inner2_target = targets[0]["id"] |
| 57 | |
| 58 | session.request("goto", {"threadId": stop.thread_id, "targetId": inner2_target}) |
| 59 | session.wait_for_next_event("continued") |
| 60 | |
| 61 | stop = session.wait_for_stop( |
| 62 | "goto", expected_frames=[some.dap.frame(code_to_debug, "inner2")] |
| 63 | ) |
| 64 | session.request_continue() |
nothing calls this directly
no test coverage detected
searching dependent graphs…