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

Function test_subprocess_unobserved

tests/debugpy/test_multiproc.py:445–499  ·  view source on GitHub ↗
(pyfile, run, target, wait)

Source from the content-addressed store, hash-verified

443@pytest.mark.parametrize("run", runners.all_attach_connect)
444@pytest.mark.parametrize("wait", ["wait", ""])
445def test_subprocess_unobserved(pyfile, run, target, wait):
446 @pyfile
447 def child():
448 from debuggee import backchannel # @bp
449
450 backchannel.send("child running")
451 backchannel.receive()
452
453 @pyfile
454 def parent():
455 import debuggee
456 import os
457 import subprocess
458 import sys
459
460 debuggee.setup()
461 args = [sys.executable, sys.argv[1]]
462 env = os.environ.copy()
463 subprocess.Popen(args, env=env).wait()
464
465 with debug.Session() as parent_session:
466 backchannel = parent_session.open_backchannel()
467
468 if not wait:
469 # The child process should have started running user code as soon as it's
470 # spawned, before there is a client connection.
471 def before_connect(address):
472 assert backchannel.receive() == "child running"
473
474 parent_session.before_connect = before_connect
475
476 with run(parent_session, target(parent, args=[child]), wait=bool(wait)):
477 pass
478
479 child_config = parent_session.wait_for_next_event("debugpyAttach")
480 parent_session.proceed()
481
482 with debug.Session(child_config) as child_session:
483 with child_session.start():
484 child_session.set_breakpoints(child, all)
485
486 if wait:
487 # The child process should not have started running user code until
488 # there was a client connection, so the breakpoint should be hit.
489 child_session.wait_for_stop(
490 expected_frames=[some.dap.frame(child, line="bp")]
491 )
492 child_session.request_continue()
493 else:
494 # The breakpoint shouldn't be hit, since that line should have been
495 # executed before we attached.
496 pass
497
498 backchannel.send("proceed")
499 child_session.wait_for_terminated()
500
501
502@pytest.mark.parametrize("run", runners.all_launch)

Callers

nothing calls this directly

Calls 11

open_backchannelMethod · 0.80
wait_for_next_eventMethod · 0.80
proceedMethod · 0.80
set_breakpointsMethod · 0.80
wait_for_stopMethod · 0.80
request_continueMethod · 0.80
runFunction · 0.70
targetFunction · 0.70
startMethod · 0.45
sendMethod · 0.45
wait_for_terminatedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…