pypidjango95% confidence\u2191 84

python coverage output: Coverage.py warning: No data was collected. (no-data-collected)

Full error message
I am trying to find the coverage using the coverage module for a django project but gets

Coverage.py warning: No data was collected. (no-data-collected)

My project folder has src and tests folders.

When I run

coverage run -m pytest && coverage report

It produces a report with 100% coverage with the list of files inside the tests folder.
Whereas when I run

coverage run --source=src -m pytest && coverage report

it says

Coverage.py warning: No data was collected. (no-data-collected)
No data to report.

When I try to give the source=src or include=src in the .coveragerc also the same warning occurs. The tests passes for all the above cases.

I want the coverage of the src folder.
Is it because I am missing some path setting?

coverage (used by pytest-cov) needs the tests folder to contain an __init__.py before it will collect any data. I added __init__.py to the tests folder and then coverage collected the data as expected. Refer to http://thomas-cokelaer.info/blog/2017/01/pytest-cov-collects-no-data-on-travis/

API access

Get this solution programmatically \u2014 free, no authentication.

curl https://depscope.dev/api/error/5d5eb956f89fc020a04bfc95dcb10ea8804f76969a86cc950daa5e7c64671589
hash \u00b7 5d5eb956f89fc020a04bfc95dcb10ea8804f76969a86cc950daa5e7c64671589
python coverage output: Coverage.py warning: No data was col… — DepScope fix | DepScope