(pyfile, target, run)
| 570 | sys.platform == "win32", reason="os.exec() is specific to POSIX" |
| 571 | ) |
| 572 | def 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) |
nothing calls this directly
no test coverage detected
searching dependent graphs…