8

VSCode has a nice stacktrace visualization and exploration tool.

Pytest has a cool feature to invoke a debugger if test cases fail. (--pdb)

If I run Pytest within the VSCode debugger, how can I get Pytest to invoke the VSCode debugger instead of the built-in PDB?

Or, failing that, how can I get PDB itself to invoke the Visual Studio stacktrace visualization?

Paul Prescod
  • 126
  • 3

1 Answers1

0

See this: https://stackoverflow.com/a/62563106/11283875

I repurposed my launch.json config a bit to run tests as a regular run/debug configuration:

{
    "name": "Debug Tests",
    "type": "python",
    "request": "launch",
    "console": "integratedTerminal",
    "module": "pytest",
    "args": ["${file}"],
    "justMyCode": false,
    "env": {
        "_PYTEST_RAISE": "1"
    }
}
Gleb Kisenkov
  • 37
  • 1
  • 7