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

1010101 picture 1010101 · Nov 14, 2017 · Viewed 18.6k times · Source

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)

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 <br/>

it says

Coverage.py warning: No data was collected. (no-data-collected) <br/>
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?

Answer

Nadav picture Nadav · Aug 27, 2018

I had the same issue and the problem was with the path I was running the tests.

What is working now:

Structure

~/Projects/ProjectName
├── manage.py
├── tests
├── src
│   ├── app_one
├── .coveragerc

Command:

~/Projects/ProjectName$ coverage run manage.py test

and my .coveragerc:

[run]
include = */src/*
omit = *migrations*, *tests*
plugins = django_coverage_plugin