I got a python script which takes command line arguments, working with some files.
I\'m writing succeeding tests with py.test putting this script through its pa
This turned out to be a problem of relative paths confusing coverage when the measured script is run from another directory. Coverage result files ended up in that directory, instead of the root directory of the project.
To solve this, I stopped using pytest-cov, and used pure coverage instead. I used full paths instead of relative paths wherever relevant.
So, e.g.
define the environment variable necessary to enable subprocess coverage via export COVERAGE_PROCESS_START=/full/path/to/.coveragerc.
In the .coveragerc, the coverage result file is specified via
[run]
data_file = /full/path/to/.coverage
and any --source and --include options should use full paths, too.
Then it was possible to get correct coverage measurement.