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
7
  • Can you show how you are running the tests, with coverage? Why do you need to run "combine" four times? Commented Jul 11, 2016 at 10:51
  • @NedBatchelder I have edited my answer. Please have a look. Commented Jul 11, 2016 at 13:10
  • I wonder if the problem is that the subprocesses don't know the name of the rcfile you used. If you name it ".coveragerc" does everything work? Commented Jul 11, 2016 at 17:09
  • @NedBatchelder I tried naming the file .coveragerc and ran the command without passing rcfile but still getting the same issue. Commented Jul 12, 2016 at 7:21
  • Sorry, I'm out of ideas. You'll need to provide me with code I can use to reproduce the issue. Commented Jul 12, 2016 at 11:41

3 Answers 3

2

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

Sign up to request clarification or add additional context in comments.

Comments

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.

1 Comment

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?
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.