When doing tests such as pytest and unittest, stepping through your own code may not solve the problem.
In such a case, you may want to debug even the installed library.
You can also set breakpoints in libraries installed with pip
etc. by making the following settings.
However, the library implemented in C language requires a method like the reference page introduced at the end of this article.
During normal debugging, not debug testing Please see Settings to debug the contents of the library with VS Code.
Normally, when debugging with vscode, I think that launch.json
often has the following settings.
launch.json
{
//You can use IntelliSense to learn the available attributes.
//Hover and display the description of existing attributes.
//Check the following for more information: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
If there is a configuration where "request" is "test", it will be used during debug testing.
Also, only the first one of this configuration will be loaded. Subsequent similar configurations will be ignored.
There is justMyCode
in this configuration, and you can switch between" ** only your own code ** ".
launch.json
{
//You can use IntelliSense to learn the available attributes.
//Hover and display the description of existing attributes.
//Check the following for more information: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
{
"name": "Debug Tests",
"type": "python",
"request": "test",
"console": "integratedTerminal",
"justMyCode": false
}
]
}
The mixed mode debugging function is called [Debugging Python and C ++ at the same time](https://docs.microsoft.com/en-us/visualstudio/python/debugging-mixed-mode-c-cpp-python-in- visual-studio? view = vs-2019) The method is provided in Visual Studio. Even with VScode, you can debug various libraries by referring to How to debug (step) mixed Python and OpenCV.
Excelsior!
Recommended Posts