A pytest plugin to easily enable debugging tests within Visual Studio Code.
WARNING: this is obsolete. VSCode supports debugging tests via configuration, e.g.:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Debug Tests",
"type": "python",
"request": "launch",
"program": "${file}",
"purpose": [
"debug-test"
],
"console": "integratedTerminal",
"justMyCode": false
}
]
}
Such configuration will be used when debugging from the "Testing" panel of VSCode.
Enables debugging a test session within Visual Studio Code, via attaching the debugger.
You can install "pytest-vscodedebug" via pip from PyPI:
$ pip install pytest-vscodedebug
You will need to configure the debugging in Visual Studio Code, via editing .vscode/launch.json
:
{
"configurations": [
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"connect": {
"host": "localhost",
"port": 10001,
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "."
}
]
}
]
}
You can enable pytest-vscodedebug when running tests with the --vscodedebug
flag:
$ py.test --vscodedebug test_testfile.py
By default, it will listen on port 10001, but you can change it via the --vscodedebug-port
option:
$ py.test --vscodedebug --vscodedebug-port=5001 test_testfile.py
Distributed under the terms of the MIT license, "pytest-vscodedebug" is free and open source software.
This code is largely based on adriencaccia's tutorial "Flask Debugging in VS Code with Hot-Reload 🔥".
If you encounter any problems, please file an issue along with a detailed description.