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

Function test_subprocess_replace

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

Source from the content-addressed store, hash-verified

570 sys.platform == "win32", reason="os.exec() is specific to POSIX"
571)
572def test_subprocess_replace(pyfile, target, run):
573 @pyfile
574 def child():
575 import os
576 import sys
577
578 assert "debugpy" in sys.modules
579
580 from debuggee import backchannel
581
582 backchannel.send(os.getpid())
583
584 @pyfile
585 def parent():
586 import debuggee
587 import os
588 import sys
589
590 debuggee.setup()
591 print(f"execl({sys.executable!r}, {sys.argv[1]!r})")
592 os.execl(sys.executable, sys.executable, sys.argv[1])
593
594 with debug.Session() as parent_session:
595 backchannel = parent_session.open_backchannel()
596 with run(parent_session, target(parent, args=[child])):
597 pass
598
599 expected_child_config = expected_subprocess_config(parent_session)
600 child_config = parent_session.wait_for_next_event("debugpyAttach")
601 child_config.pop("isOutputRedirected", None)
602 assert child_config == expected_child_config
603 parent_session.proceed()
604
605 with debug.Session(child_config) as child_session:
606 with child_session.start():
607 pass
608
609 child_pid = backchannel.receive()
610 assert child_pid == child_config["subProcessId"]
611 assert str(child_pid) in child_config["name"]
612
613
614@pytest.mark.parametrize("run", runners.all_launch)

Callers

nothing calls this directly

Calls 9

open_backchannelMethod · 0.80
wait_for_next_eventMethod · 0.80
popMethod · 0.80
proceedMethod · 0.80
receiveMethod · 0.80
runFunction · 0.70
targetFunction · 0.70
startMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…