coverage.py: exclude files

flybywire picture flybywire · Oct 13, 2009 · Viewed 21.2k times · Source

How do I exclude entire files from coverage.py reports?

According to the documentation you can exclude code by matching lines. I want to exclude entire files, so that the reports don't include 3rd party libraries. Am I missing something? Can it be done?

Answer

Ned Batchelder picture Ned Batchelder · Oct 13, 2009

You can omit modules with the --omit flag. It takes a comma-separated list of path prefixes. So for example:

coverage run my_program.py
coverage report --omit=path/to/3rdparty