Setting up coverage.py with flask Setting up coverage.py with flask flask flask

Setting up coverage.py with flask


Got it working -- thanks to some guidance from @NedBat.

The issue was the gunicorn was spawning off additional subprocesses -- and those where not being monitored.

To solve this I needed to leverage the site module's sitepackage.py feature. Which in total fairness was documented http://nedbatchelder.com/code/coverage/subprocess.html -- but I was just doing it wrong.

You need to create that sitepackage.py file and place it in your site-packages folder. And then any process (or subprocess) that runs in the environment will execute that file before starting the process.


If you use nose for testing, then it's pretty trivial. Just run:

nosetests --with-coverage --cover-package=yourpackagename--cover-html --cover-erase