Identifying python files with no coverage

History / Edit / PDF / EPUB / BIB /
Created: February 27, 2020 / Updated: November 2, 2024 / Status: finished / 1 min read (~127 words)
Problems Python

I use pytest with coverage and I want to see the files that have no coverage.

It appears that pytest and pytest-cov will not list someof the files that are under namespace packages, while it will work fine for files in regular packages (see PEP 420 on the topic of implicit namespace packages).

To fix this problem, one solution is to add __init__.py files in all of your directories in order to create regular packages.

If you are using PyCharm Professional, you can simply run your test with coverage. This will allow you to identify all the files that have currently no coverage as they will appear with coverage = 0%.