我正在try 用VS代码调试Python Pytest测试,使用左栏上的测试活动.我能够按照预期运行测试,有些通过,有些失败.我想调试失败的测试,以更准确地确定导致失败的原因.
当我在调试模式下运行单个测试时,VS代码正确地命中断点并停止,并且运行和调试窗格显示了局部变量.我可以在变量中观察局部变量的状态>;本地窗格或通过REPL,键入变量的名称.
当我试图打印任何语句时,例如使用> print("here")
,我不会得到任何输出到调试控制台.当我引用一个变量,或者直接使用> "here"
放置字符串时,我确实看到了调试控制台的输出.
在我看来,REPL的stdout没有显示在调试控制台上.许多在线答案都建议增加"redirectOutput": true
或"console": "integratedTerminal"
这样的选项,但这两个选项似乎都不起作用.下面是我的全部简历:
{
// 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"
}
]
}
我是否缺少另一个设置来启用此输出?我的控制台型号错了吗?