(pyfile, target, run)
| 153 | |
| 154 | @pytest.mark.parametrize("run", runners.all_attach_connect) |
| 155 | def 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"]) |
nothing calls this directly
no test coverage detected
searching dependent graphs…