coverage.py

Exclude directory but include file in coverage.py reports?


I want to exclude tests directories, but include one file from the tests directory. Example .coveragerc:

[run]
omit =
    */tests/*
    !*/myapp/tests/my_file.py

but I think coverage.py doesn't support a "!" syntax to "not omit" files.

Do I have to explicitly list all the files to include instead, or is there a simpler way?


Solution

  • I don't think there's a way to do this. The docs say:

    If both include and omit are specified, first the set of files is reduced to only those that match the include patterns, then any files that match the omit pattern are removed from the set.