-
Notifications
You must be signed in to change notification settings - Fork 95
When debugging pytest test case, debugger detatches when subprocess.run invokes python #993
Copy link
Copy link
Closed
Labels
triage-neededNeeds assignment to the proper sub-teamNeeds assignment to the proper sub-team
Description
I have tests with pytest, where, if I try to use subprocess.run to invoke another instance of the python interpreter during my test, and then I try to step through that test with a debugger, the python debugger detaches.
If I connect the debugger to the file itself, instead of running on the test case, it is able to step over every line of code, and does not detach. However if I use the "Testing" menu on the left hand side of VSCode to run test cases with a debugger (or selecting the icon next to the test), the debugger will detatch after the line subprocess.run:
Below is a snippet that reproduces the issue.
import subprocess
def test_subprocess():
stdout = subprocess.run(
["python", "-c", "print('Hello')"],
text=True,
capture_output=True,
).stdout
assert stdout == "Hello\n"
if __name__ == "__main__":
test_subprocess()My ms-python.debugpy version is 2025.18.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
triage-neededNeeds assignment to the proper sub-teamNeeds assignment to the proper sub-team