Repository navigation
Expand file tree
/
Copy pathtest_step.py
More file actions
64 lines (49 loc) · 1.88 KB
/
Copy pathtest_step.py
File metadata and controls
64 lines (49 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See LICENSE in the project root
# for license information.
import pytest
from tests import debug
from tests.patterns import some
def test_set_next_statement(pyfile, run, target):
@pyfile
def code_to_debug():
import debuggee
debuggee.setup()
def func():
print(1) # @inner1
print(2) # @inner2
print(3) # @outer3
func()
line_numbers = code_to_debug.lines
with debug.Session() as session:
with run(session, target(code_to_debug)):
session.set_breakpoints(code_to_debug, ["inner1"])
stop = session.wait_for_stop(
expected_frames=[some.dap.frame(code_to_debug, "inner1")]
)
targets = session.request(
"gotoTargets",
{"source": {"path": code_to_debug}, "line": line_numbers["outer3"]},
)["targets"]
assert targets == [
{"id": some.number, "label": some.str, "line": line_numbers["outer3"]}
]
outer3_target = targets[0]["id"]
with pytest.raises(Exception):
session.request(
"goto", {"threadId": stop.thread_id, "targetId": outer3_target}
)
targets = session.request(
"gotoTargets",
{"source": {"path": code_to_debug}, "line": line_numbers["inner2"]},
)["targets"]
assert targets == [
{"id": some.number, "label": some.str, "line": line_numbers["inner2"]}
]
inner2_target = targets[0]["id"]
session.request("goto", {"threadId": stop.thread_id, "targetId": inner2_target})
session.wait_for_next_event("continued")
stop = session.wait_for_stop(
"goto", expected_frames=[some.dap.frame(code_to_debug, "inner2")]
)
session.request_continue()