Debugging Python Tests in VSCode

Debugging Python Tests in VSCode

VSCode offers native test capabilities that are quite useful. Testing Python in Visual Studio Code

It doesn’t, however, recognize your Python tests by default. You must configure it to do so for each project.

Command Palette (CTRL+SHIFT+P) → “Python: Configure Tests” →

Command Palette Python Configure Tests.png

Select the framework you’re using:

Command Palette Select Framework.png

Now, you get all of the testy-goodness that VSCode has to offer for Python.

In this case, I wanted to debug a specific test. Super easy! Just drop breakpoints in the test where you want them, then run “Debug Test”.

Right Click Debug Test.png

The “Test Explorer” is also quite useful.

links