pytest-cov icon indicating copy to clipboard operation
pytest-cov copied to clipboard

omit from .coveragerc isn't working

Open zulrang opened this issue 6 years ago • 2 comments

On the configuration page in the documentation (https://pytest-cov.readthedocs.io/en/latest/config.html) it specifies how to omit tests/* from coverage reporting.

Following the instructions exactly results in tests/* still being covered.

zulrang avatar May 23 '18 15:05 zulrang

What do you use exactly i.e. what is your .coveragerc? You likely are missing it in [report] I guess. Are the files reported to be covered in some way? AFAIK omit in [run] should result in 0% coverage, but report would still include it by default.

I think the docs could need an update then, and should also link to http://coverage.readthedocs.io/en/latest/config.html. Do you feel like creating a PR for this?

blueyed avatar May 23 '18 16:05 blueyed

I'm seeing the same behavior:

.coveragerc

[report]
omit =
    */migrations/*.py
    */management/commands/*.py
    */admin.py
    dubclub/settings/prod.py
    dubclub/settings/next.py
    dubclub/settings/demo.py
    dubclub/settings/ui.py
    dubclub/?sgi.py

All of the management/commands/*.py are listed as 0% coverage but the migrations were omitted

Turns out the command line had -omit on it (for the migrations) and that made it ignore this option from the file. Re-running without the command line option made it work for me.

boatcoder avatar Feb 22 '22 17:02 boatcoder