MCPcopy Create free account
hub / github.com/microsoft/debugpy / test_with_path_mappings

Function test_with_path_mappings

tests/debugpy/test_path_mapping.py:60–146  ·  view source on GitHub ↗
(pyfile, long_tmpdir, target, run)

Source from the content-addressed store, hash-verified

58
59
60def test_with_path_mappings(pyfile, long_tmpdir, target, run):
61 @pyfile
62 def code_to_debug():
63 import debuggee
64 import os
65 import sys
66 from debuggee import backchannel
67
68 debuggee.setup()
69 backchannel.send(os.path.abspath(__file__))
70 call_me_back_dir = backchannel.receive()
71 sys.path.insert(0, call_me_back_dir)
72
73 import call_me_back
74
75 def call_func():
76 print("break here") # @bp
77
78 call_me_back.call_me_back(call_func) # @call_me_back
79 print("done")
80
81 dir_local = long_tmpdir.mkdir("local")
82 dir_remote = long_tmpdir.mkdir("remote")
83
84 path_local = dir_local / "code_to_debug.py"
85 path_remote = dir_remote / "code_to_debug.py"
86
87 code_to_debug.copy(path_local)
88 code_to_debug.copy(path_remote)
89
90 call_me_back_dir = test_data / "call_me_back"
91 call_me_back_py = call_me_back_dir / "call_me_back.py"
92
93 with debug.Session() as session:
94 session.config["pathMappings"] = [
95 {"localRoot": dir_local, "remoteRoot": dir_remote}
96 ]
97
98 backchannel = session.open_backchannel()
99 with run(session, target(path_remote)):
100 # Set breakpoints using local path. This tests that local paths are
101 # mapped to remote paths.
102 session.set_breakpoints(path_local, ["bp"])
103
104 actual_path_remote = backchannel.receive()
105 assert some.path(actual_path_remote) == path_remote
106 backchannel.send(call_me_back_dir)
107
108 stop = session.wait_for_stop(
109 "breakpoint",
110 expected_frames=[
111 some.dap.frame(
112 # Mapped files should not have a sourceReference, so that the IDE
113 # doesn't try to fetch them instead of opening the local file.
114 some.dap.source(path_local, sourceReference=0),
115 line="bp",
116 ),
117 some.dap.frame(

Callers

nothing calls this directly

Calls 13

open_backchannelMethod · 0.80
set_breakpointsMethod · 0.80
receiveMethod · 0.80
pathMethod · 0.80
wait_for_stopMethod · 0.80
not_equal_toMethod · 0.80
request_continueMethod · 0.80
runFunction · 0.70
targetFunction · 0.70
copyMethod · 0.45
sendMethod · 0.45
sourceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…