How to get combined code coverage with multiple Python script runs

I have a python program that is tested by running it several times with different inputs and comparing the outputs with the comparison results.

I would like to get the code coverage of all tests in combination, so I can see if there are additional sets of inputs that I have to use to get full coverage. I looked at the coverage module, but cannot figure out how I can do this.

Any clues?

+7
python code-coverage python-coverage
source share
2 answers

Ned Batchelder coverage.py has a function to combine the results of several starts , which seems to be exactly what you are looking for.

+3
source share

When running on one computer, run it with the -a option, which accumulates coverage data for several calls.

Example:

 coverage erase coverage run -a <command> [arguments, ...] repeat coverage run -a <command> ... as many times as needed. coverage report coverage html 

doc: http://coverage.readthedocs.org/en/latest/cmd.html#data-file

Hope this helps.

+9
source share

All Articles