Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignoring empty files from coverage report

Tags:

coverage.py will include init.py in its report and show it as 0 lines, but with 100% coverage.

I want to exclude all blank files from coverage report. I can't just add */__init__.py to omit as some of my __init__.py files have code.

like image 260
shabda Avatar asked Jan 06 '14 14:01

shabda


2 Answers

From the docs and docs: "New in version 5.0: The contexts and skip_empty parameters." In your tox.ini file or .coveragerc file add the following:

[coverage:report] skip_empty = true 

"If skip_empty is true, don’t report on empty files (those that have no statements)."

"skip_empty (boolean, default False): Don’t include empty files (those that have 0 statements) in the report. See Coverage summary for more information."

like image 197
bwl1289 Avatar answered Sep 18 '22 23:09

bwl1289


This feature doesn't exist in coverage.py. Does it help that you can sort the HTML report to move 100% files to the bottom, or files with 0 statements to the bottom?

UPDATE: As of coverage.py 4.0, the --skip-covered option is available to do exactly what is requested.

like image 40
Ned Batchelder Avatar answered Sep 18 '22 23:09

Ned Batchelder