Suppose I have the following code in foo.py
:
def start():
"""
>>> start()
Hello world
"""
test = 10
print('Hello world')
Normally, I would run the doctest by running pytest foo.py --doctest-modules -v
in the terminal. I instead want to be able to test it through Visual Studio Code's built-in debugger to track the variables and call stack.
I have the following configuration in my project's launch.json
:
"name": "PyTest",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"pythonPath": "${config:python.pythonPath}",
"module": "pytest",
"args": [
"${file}",
"--doctest-modules",
"-v"
],
"cwd": "${workspaceRoot}",
"env": {},
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"RedirectOutput"
]
However, when I open the file and run the PyTest debugging configuration in the VSCode debugger, the doctests are only run in the built-in terminal - nothing shows up in the debugger panel. How should I configure the debugger to be able to use its variables and call stack?