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

Function test_reattach

tests/debugpy/test_attach.py:155–200  ·  view source on GitHub ↗
(pyfile, target, run)

Source from the content-addressed store, hash-verified

153
154@pytest.mark.parametrize("run", runners.all_attach_connect)
155def test_reattach(pyfile, target, run):
156 @pyfile
157 def code_to_debug():
158 import time
159 import debuggee
160 import debugpy
161 from debuggee import scratchpad
162
163 debuggee.setup()
164 debugpy.breakpoint()
165 object() # @first
166
167 scratchpad["exit"] = False
168 while not scratchpad["exit"]:
169 time.sleep(0.1)
170 debugpy.breakpoint()
171 object() # @second
172
173 with debug.Session() as session1:
174 session1.captured_output = set()
175 session1.expected_exit_code = None # not expected to exit on disconnect
176
177 with run(session1, target(code_to_debug)):
178 expected_adapter_sockets = session1.expected_adapter_sockets.copy()
179
180 session1.wait_for_stop(expected_frames=[some.dap.frame(code_to_debug, "first")])
181 session1.disconnect()
182
183 with debug.Session() as session2:
184 session2.config.update(session1.config)
185 session2.expected_adapter_sockets = expected_adapter_sockets
186 if "connect" in session2.config:
187 session2.connect_to_adapter(
188 (session2.config["connect"]["host"], session2.config["connect"]["port"])
189 )
190
191 with session2.request_attach():
192 pass
193
194 session2.wait_for_stop(
195 expected_frames=[some.dap.frame(code_to_debug, "second")]
196 )
197 session2.scratchpad["exit"] = True
198 session2.request_continue()
199
200 session1.wait_for_exit()
201
202
203@pytest.mark.parametrize("pid_type", ["int", "str"])

Callers

nothing calls this directly

Calls 10

wait_for_stopMethod · 0.80
connect_to_adapterMethod · 0.80
request_attachMethod · 0.80
request_continueMethod · 0.80
wait_for_exitMethod · 0.80
runFunction · 0.70
targetFunction · 0.70
copyMethod · 0.45
disconnectMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…