(pyfile, target, run)
| 248 | |
| 249 | @pytest.mark.parametrize("run", runners.all_launch) |
| 250 | def test_autokill(pyfile, target, run): |
| 251 | @pyfile |
| 252 | def child(): |
| 253 | import os |
| 254 | from debuggee import backchannel |
| 255 | |
| 256 | backchannel.send(os.getpid()) |
| 257 | while True: |
| 258 | pass |
| 259 | |
| 260 | @pyfile |
| 261 | def parent(): |
| 262 | import debuggee |
| 263 | import os |
| 264 | import subprocess |
| 265 | import sys |
| 266 | |
| 267 | debuggee.setup() |
| 268 | argv = [sys.executable, sys.argv[1]] |
| 269 | env = os.environ.copy() |
| 270 | subprocess.Popen( |
| 271 | argv, |
| 272 | env=env, |
| 273 | stdin=subprocess.PIPE, |
| 274 | stdout=subprocess.PIPE, |
| 275 | stderr=subprocess.PIPE, |
| 276 | ).wait() |
| 277 | |
| 278 | with debug.Session() as parent_session: |
| 279 | parent_session.expected_exit_code = some.int |
| 280 | |
| 281 | backchannel = parent_session.open_backchannel() |
| 282 | with run(parent_session, target(parent, args=[child])): |
| 283 | pass |
| 284 | |
| 285 | child_config = parent_session.wait_for_next_event("debugpyAttach") |
| 286 | parent_session.proceed() |
| 287 | |
| 288 | with debug.Session(child_config) as child_session: |
| 289 | with child_session.start(): |
| 290 | pass |
| 291 | |
| 292 | child_pid = backchannel.receive() |
| 293 | assert child_config["subProcessId"] == child_pid |
| 294 | child_process = psutil.Process(child_pid) |
| 295 | |
| 296 | parent_session.request("terminate") |
| 297 | child_session.wait_for_exit() |
| 298 | |
| 299 | log.info("Waiting for child process...") |
| 300 | child_process.wait() |
| 301 | |
| 302 | |
| 303 | @pytest.mark.parametrize("run", runners.all_launch) |
nothing calls this directly
no test coverage detected
searching dependent graphs…