Member-only story
Configuring VSCode To Run Python Tests With Both Code Coverage And Debugging Enabled
Another Simple-But-Not-Trivial Hack
Python tooling is always a little weird and usually very tedious. Over the course of the past few months I’ve dabbled in setting up VSCode to produce code coverage reports, and while I haven’t quite got coverage gutters working (apparently all of those extensions require lcov reports, and apparently that’s not a trivial thing for pytest to produce) I have finally got code coverage reports and debugging working without having to rewrite my configuration files every time, so I thought I’d share my learnings with the rest of the class.
I’ll start by citing one of my many sources, this Python extension issue:
In short, debugging is disabled automatically while a code coverage report is being produced. In order to make both functionalities available, you will need to update the following two configurations:
- .vscode/settings.json