pytest-cov icon indicating copy to clipboard operation
pytest-cov copied to clipboard

pytest-cov randomly fails with `INTERNALERROR> coverage.misc.CoverageException: Can't combine line data with arc data`

Open jacek-jablonski opened this issue 4 years ago • 4 comments

Summary

Running pytest with pytest-cov plugin or coverage standalone randomly results in error:

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/Users/jacek/temp/coverage-error/.venv/lib/python3.8/site-packages/_pytest/main.py", line 269, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/Users/jacek/temp/coverage-error/.venv/lib/python3.8/site-packages/_pytest/main.py", line 323, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/Users/jacek/temp/coverage-error/.venv/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/Users/jacek/temp/coverage-error/.venv/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/jacek/temp/coverage-error/.venv/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>
INTERNALERROR>     self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR>   File "/Users/jacek/temp/coverage-error/.venv/lib/python3.8/site-packages/pluggy/callers.py", line 203, in _multicall
INTERNALERROR>     gen.send(outcome)
INTERNALERROR>   File "/Users/jacek/temp/coverage-error/.venv/lib/python3.8/site-packages/pytest_cov/plugin.py", line 271, in pytest_runtestloop
INTERNALERROR>     self.cov_controller.finish()
INTERNALERROR>   File "/Users/jacek/temp/coverage-error/.venv/lib/python3.8/site-packages/pytest_cov/engine.py", line 44, in ensure_topdir_wrapper
INTERNALERROR>     return meth(self, *args, **kwargs)
INTERNALERROR>   File "/Users/jacek/temp/coverage-error/.venv/lib/python3.8/site-packages/pytest_cov/engine.py", line 230, in finish
INTERNALERROR>     self.cov.stop()
INTERNALERROR>   File "/Users/jacek/temp/coverage-error/.venv/lib/python3.8/site-packages/coverage/control.py", line 701, in combine
INTERNALERROR>     combine_parallel_data(
INTERNALERROR>   File "/Users/jacek/temp/coverage-error/.venv/lib/python3.8/site-packages/coverage/data.py", line 117, in combine_parallel_data
INTERNALERROR>     data.update(new_data, aliases=aliases)
INTERNALERROR>   File "/Users/jacek/temp/coverage-error/.venv/lib/python3.8/site-packages/coverage/sqldata.py", line 574, in update
INTERNALERROR>     raise CoverageException("Can't combine line data with arc data")
INTERNALERROR> coverage.misc.CoverageException: Can't combine line data with arc data

Expected vs actual result

pytest-cov running without error

Reproducer

Minimal example: https://github.com/jacek-jablonski/coverage-test-error

Versions

Output of relevant packages pip list, python --version, pytest --version etc.

coverage=5.5 pytest=6.2.4 pytest-cov=2.12.1

Config

Provided in a minimal example

Code

Provided in a minimal example

If you paste raw code make sure you quote it, eg:

jacek-jablonski avatar Jul 24 '21 19:07 jacek-jablonski

I had something very similar with green, not pytest, and it turned out to be caused by a stale .coverage file. Deleting that file completely resolved it for me. Have you double checked that this is reproducible in a clean environment, and if not maybe have pytest-cov delete the .coverage file before a run?

sodul avatar Jul 30 '21 06:07 sodul

Hi @sodul, Deleting .coverage doesn't change the situation. It still happens in a clean environment.

jacek-jablonski avatar Aug 02 '21 07:08 jacek-jablonski

Ok. What I seem to understand from the error message is that the coverage information gets 'corrupted' and when coverage.py tries to aggregate the data it barfs by saying that line coverage and branch coverage (that's what I suppose arc data means here) cannot be combined.

Personally I do believe that there might be something wrong in pytest-cov that triggers the bug, the bug itself is very likely in coverage.py itself since coverage.py is the one reading/writing the data and it ends up not agreeing with itself.

I'm not a coverage.py maintainer and I do not use pytest so I'm not able to help more than sharing my own experience with this error message.

Good luck @jacek-jablonski

sodul avatar Aug 02 '21 18:08 sodul

the bug itself is very likely in coverage.py itself since coverage.py is the one reading/writing the data and it ends up not agreeing with itself.

Meanwhile, coverage.py people say (nedbat/coveragepy/issues/512)

it seems to be about pytest-cov, not coverage.py, and 2) there's a fix, which is to explicitly name your coverage configuration file with --cov-config.

charmoniumQ avatar Sep 15 '22 00:09 charmoniumQ