I am trying to debug my Python Pytest tests in VS Code, using the Testing Activity on the left bar. I am able to run my tests as expected, with some passing and some failing. I would like to debug the failing tests to more accurately determine what is causing the failures.
When I run an individual test in debug mode VS Code is properly hitting a breakpoint and stopping, and the Run and Debug pane shows the local variables. I can observe the status of local variables either in the Variables > Local pane or through the REPL, by typing the name of the variable.
When I try to print out any statement, such as using > print("here")
I do not get any output to the Debug Console. When I reference a variable, or put the string directly using > "here"
I do see the output to the Debug Console.
It seems to me that the stdout of my REPL is not displaying to the Debug Console. A number of answers online have been suggesting to add options like "redirectOutput": true
or "console": "integratedTerminal"
, but neither of those seem to have worked. My full launch.json
is below:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit"
],
"console": "integratedTerminal",
"stopOnEntry": false,
"redirectOutput": true,
"outputCapture": "std"
}
]
}
Is there another setting I'm missing to enable this output? Have I got the wrong console type?
pytest
– Crippen