question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pytest and multiprocessing: CoverageException: Can't combine line data with arc dat

See original GitHub issue

Originally reported by Samuel Colvin (Bitbucket: samuelcolvin, GitHub: samuelcolvin)


I’m getting CoverageException: Can't combine line data with arc dat when using coverage with the pytest-cov pytest extension. I think this is similar to #399, but that issue is closed.

Example failure on travis: https://travis-ci.org/samuelcolvin/arq/builds/148541711

The test causing problems is using click’s CliRunner, code here. The CLI command that’s testing starts another process (using multiprocessing.Process) to run the worker which is what’s causing the problem, if you prevent the worker process being started the exception doesn’t occur.

I tried changing the concurrency mode but it made no difference.

To reproduce: clone, pip install -e . && pip install -r tests/requirements.txt, py.test --cov=arq.

relevant bits of pip freeze:

click==6.6
coverage==4.2
pytest==2.9.2
pytest-cov==2.3.0

Let me know if you need anymore information.


Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:40 (25 by maintainers)

github_iconTop GitHub Comments

3reactions
nedbatcommented, Jun 23, 2018

Original comment by Ionel Cristian Mărieș (Bitbucket: ionelmc, GitHub: ionelmc)


I’ve taken a look at this as well, my opinion is that a combination of configuration, subprocess use and cwd changes cause the problem. That’s why you get the data file saved without arcs (branch=False).

There are thee ways to deal with this:

  • Specify --cov-config=setup.cfg (pytest-cov will absolutize it before tmpworkdir is used). Alternatively, you could use a .coveragerc (pytest-cov absolutize that if it exists).
  • Fix the test to not use subprocesses. Afaik the test spawns a suprocess that sigterms the parent. This makes no sense to me - you can do that with no subprocess at all. Eg: signal.kill(os.getpid(), signal.SIGTERM) or even a thread.
  • Stop changing current working directory (tmpworkdir fixture).

There is no bug in either coverage or pytest-cov here.

Also, note that concurrency = multiprocessing is completely un-necessary if you use pytest-cov (it completely manages coverage measurements in subprocesses for you).

1reaction
wohalicommented, Apr 18, 2022

I get this error when I use branch = true. @wohali @joshfriend can you confirm this with your repo?

Yes, I use branch = true. As I understand it this changes the format of the file, as I mentioned above, so the results cannot be combined with runs that don’t include that. Something to do with multiprocess runs and the toml file not being included caused the mixed format issue for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CoverageException: Can't combine line data with arc dat
The test causing problems is using click's CliRunner , code here. The CLI command that's testing starts another process (using multiprocessing.
Read more >
Merge branch coverage files python - Stack Overflow
I am trying to merge coverage reports but I am not able to do in a single shot. Following is the issue I...
Read more >
Change history for coverage.py - Read the Docs
The coverage combine command now prints messages indicating each data file being combined. Fixes issue 1105. The HTML report now includes a sentence...
Read more >
mozilla-release: changeset 682745 ... - Mercurial
third_party/python/coverage/requirements/pytest.pip ... This would lead to a "Can't combine line data with arc data" error - message.
Read more >
Overview - Joe Sandbox
Urls found in memory or binary data, Show sources ... It cannot. ... __str__(self):. return "".join(str(c) for c in self.code).. def add_line(self, line):....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found