3

I have a multiprocessing application in python. And I am trying to get the coverage report after running my tests. I am trying to merge coverage reports but I am not able to do in a single shot.

Following is the issue I am facing. My two tests have generated 4 coverage files. And when I run the command "coverage combine" I get the following error:

Can't combine line data with arc data

To merge the coverage files I need to run "coverage combine" command 4 times. But I am planning to add more tests and that will make combining the reports even difficult.

So how can I combine all the coverage reports in a single go?

PS: I have set the configuration file as follows:

[run]
branch = True
parallel = True
concurrency = multiprocessing

[report]
# Regexes for lines to exclude from consideration
exclude_lines =
    # Have to re-enable the standard pragma
    pragma: no cover

And I am able to get the combined report correctly for line coverage.

EDIT:

This is how I run my application to get the coverage

coverage --rcfile=coverage_rc_file tester_script.py test1 test2

The above command runs my app twice and generates 4 coverage files.

Then I run the following command to combine the results:

coverage combine

3 Answers3

2

I encountered the same error. The problem was caused by the stale files from the previous runs. Removing .coverage.* files helped.

frantisek
  • 201
  • 2
  • 7
1

The error you are seeing will happen if you use the command line to configure coverage, like this:

coverage run --branch --concurrency=multiprocessing myprogram.py

The problem is that the command line arguments aren't communicated down to the subprocesses, so the main process measures branch coverage, and the subprocesses measure line coverage. Then the combine step can't combine the files.

The fix is to use a .coveragerc configuration file. But you say you are using that, so I'm not sure what's going wrong, unless you had started with just command-line arguments.

Ned Batchelder
  • 364,293
  • 75
  • 561
  • 662
  • Yes, I have added those parameters in a config file. But still I'am getting the error. Any suggestions that I can try to resolve this issue? – Shrihari Voniyadka Jul 11 '16 at 05:18
1

I ran across this problem when my unit tests ran code in multiple directories. I had to add .coveragerc files in each directory to get them all to produce branch (aka arc) data. I did this by sym-linking to my main .coveragerc file.

Mike Jarvis
  • 889
  • 6
  • 17