.coveragerc file location when running py.test

Reading the pytest documentation again and again...I found my "mistake":
Here it says:

Note that this plugin controls some options and setting the option in the config file will have no effect. These include specifying source to be measured (source option) and all data file handling (data_file and parallel options).

So my test was useless because the data_file option in .coveragerc has no effect.

I tested with the omit option and it worked!

.coveragerc has to be placed in the basepath as described above (and expected)


I believe the answer changed a bit. Taken from https://pytest-cov.readthedocs.io/en/latest/config.html

You can point pytest-cov to a config file like this:

pytest --cov-config=.coveragerc
       --cov=myproj
       myproj/tests/

This plugin overrides the data_file and parallel options of coverage. Unless you also run coverage without pytest-cov it’s pointless to set those options in your .coveragerc.

If you use the --cov=something option (with a value) then coverage’s source option will also get overriden. If you have multiple sources it might be easier to set those in .coveragerc and always use --cov (wihout a value) instead of having a long command line with --cov=pkg1 --cov=pkg2 --cov=pkg3 ....

If you use the --cov-branch option then coverage’s branch option will also get overriden.

Therefore, the source option can be specified (at least if you run it with --cov without a value)