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.

tox tests + branch coverage + coverage combine = internal error

See original GitHub issue

Hi,

I added coverage to the tests of the tox project and stumbled over a problem when trying to record branch coverage. The problem is os independent and can be reproduced easily with the code of the tox project.

versions:

coverage==4.4.1
py==1.4.34
pytest==3.2.1
pytest-cov==2.5.1

reproduce:

$ git clone git@github.com:tox-dev/tox.git
$ cd tox
$ pip install -e .
$ pip install pytest pytest-cov 
$ pytest tests/test_z_cmdline.py::TestToxRun --cov-branch --cov=tox

result:

========================================================== test session starts ===========================================================
platform linux -- Python 3.6.2, pytest-3.2.1, py-1.4.34, pluggy-0.4.0
tox comes from: '/home/oliver/work/tox/tox/tox/__init__.py'
rootdir: /home/oliver/work/tox/tox, inifile: tox.ini
plugins: cov-2.5.1
collected 3 items                                                                                                                                                             

tests/test_z_cmdline.py ...
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "[...]/_pytest/main.py", line 110, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "[...]/_pytest/main.py", line 146, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "[...]/_pytest/vendored_packages/pluggy.py", line 745, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "[...]/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "[...]/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "[...]/_pytest/vendored_packages/pluggy.py", line 613, in execute
INTERNALERROR>     return _wrapped_call(hook_impl.function(*args), self.execute)
INTERNALERROR>   File "[...]/_pytest/vendored_packages/pluggy.py", line 250, in _wrapped_call
INTERNALERROR>     wrap_controller.send(call_outcome)
INTERNALERROR>   File "[...]/pytest_cov/plugin.py", line 235, in pytest_runtestloop
INTERNALERROR>     self.cov_controller.finish()
INTERNALERROR>   File "[...]/pytest_cov/engine.py", line 154, in finish
INTERNALERROR>     self.cov.stop()
INTERNALERROR>   File "[...]/coverage/control.py", line 809, in combine
INTERNALERROR>     self.data, aliases=aliases, data_paths=data_paths, strict=strict,
INTERNALERROR>   File "[...]/coverage/data.py", line 735, in combine_parallel_data
INTERNALERROR>     data.update(new_data, aliases=aliases)
INTERNALERROR>   File "[...]/coverage/data.py", line 488, 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

======================================================= 3 passed in 17.21 seconds ========================================================

There are a lot of timestamped .coverage.* files and all except for the first one contain “arc” data - the first one contains “lines” data - which causes the error.

I have not yet tried to reproduce this with vanilla coverage as the reason I use pytest-cov is that there are a lot of tests that run in a subprocess and pytest-cov takes care of that. It might be that the problem is actually in coverage.py itself but I thought I report this here first.

pytest tests/test_z_cmdline.py::TestToxRun --cov=tox works.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
obestwaltercommented, Sep 6, 2017

Hi @ionelmc - thanks. I don’t quite understand how that workaround you proposed would work, but a workaround that works already is passing the path to the pytest-cov like:

 pytest --cov-config=tox.ini --cov=tox

So that works and is good enough for me at the moment.

0reactions
blueyedcommented, Nov 15, 2018

You can use export COVERAGE_DEBUG=process,config,dataio (or similar, see coverage.py docs) to debug this (look at “config_files”, cwds etc).

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I combine coverage results with tox? - Stack Overflow
This will combine the coverage from multiple test runs together. This is also helpful if you split out integration/unit tests.
Read more >
Change history for coverage.py - Read the Docs
Coverage.py uses CPython internal fields which are moving during the alpha phase. ... Improved the error message when combining line and branch data, ......
Read more >
pytest-cov - Read the Docs
1.4 Coverage Data File. The data file is erased at the beginning of testing to ensure clean data for each test run. If...
Read more >
Test coverage visualization - GitLab Docs
Once configured, if you create a merge request that triggers a pipeline which collects coverage reports, the coverage is shown in the diff...
Read more >
Test Coverage - DeepSource Docs
[run] branch = True source = src omit = .tox/* env/*. With multiple python versions, combine the coverage data files before reporting. Example...
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