I am trying to find the coverage using coverage module for a django project but gets
Coverage.py warning: No data was collected. (no-data-collected)
The problem is that you're not specifying which dir to get coverage from.
You can specify that in the .coveragerc file or on the command line:
pytest tests -v --cov-report term --cov-report html:htmlcov --cov-report xml --cov-fail-under=90 --cov=
If you desire you can only execute pytest tests and add pytest args on pytest.ini at your project root:
[pytest]
addopts = -v --cov-report term --cov-report html:htmlcov --cov-report xml --cov-fail-under= --cov=
Bonus:
If you want to omit files from the coverage you can add a .coveragerc file on your project root:
[run]
omit =
# omit everything in the folder
proj-ab/api/confs/
# omit file
proj-ab/models/file-not-covered.py
Requirements:
On these examples I'm using requirements: pytest==4.6.2 and pytest-cov==2.7.1