如何让 Pytest 调用 VSCode 断点视图而不是 PDB

Pau*_*cod 7 pytest visual-studio-code

VSCode 有一个很好的堆栈跟踪可视化和探索工具。

如果测试用例失败,Pytest 有一个很酷的功能来调用调试器。(--pdb)

如果我在 VSCode 调试器中运行 Pytest,如何让 Pytest 调用 VSCode 调试器而不是内置 PDB?

或者,如果失败了,我怎样才能让 PDB 本身调用 Visual Studio 堆栈跟踪可视化?

小智 0

请参阅:/sf/answers/4379417451/

我重新调整了 launch.json 配置的用途,将测试作为常规运行/调试配置运行:

{
    "name": "Debug Tests",
    "type": "python",
    "request": "launch",
    "console": "integratedTerminal",
    "module": "pytest",
    "args": ["${file}"],
    "justMyCode": false,
    "env": {
        "_PYTEST_RAISE": "1"
    }
}
Run Code Online (Sandbox Code Playgroud)