I'm developing a module1 which has some test cases. I've another module2 which can run these test cases and generate the amount of coverage. Currently the .coverage folder is generated on the current working directory from where the module2 is being called. Is there a way to specify the folder path for coverage to dump this .coverage in the path specified?
Provide path to Coverage to dump .coverage
2.5k Views Asked by V.i.K.i At
2
There are 2 best solutions below
0

There are several ways you can do this, depending on how you are running your tests.
- For xml report mode, use coverage xml -o <<your_file>>
- For html report mode, use coverage html -d <<your_output_directory>>
- To use a coverage config file, use either coverage xml --rcfile=<<your_config_file>> or coverage html --rcfile=<<your_config_file>> and then use the coverage config options to set the appropriate paths
That last option (config file) is especially useful if you are running coverage through some other tool like nose. Often, the test runner will only give you a minimal set of options and the config file gives you a lot more control.
Hope this helps!
Seems like from command line there is no option to do this. But using configuration files this can be done.
In the configuration file keep below lines.
[run]
data_file = < path where .coverage should be stored >
Then run:
coverage run < script > (if configuration file is not specified, it looks for .coveragerc in same folder from when coverage is being run. If this is also not available then defaults are used)
or
coverage run --rcfile < configuration file name > < script name >