Description
I want to use Coverage to report across multiple Tox envs. Since each Tox env uses a separate virtualenv, I specify paths
in Coverage's config:
[coverage:paths]
source =
src
.tox/*/lib/python*/site-packages
.tox/*/site-packages
My package is under the src directory. The first tox path applies to CPython envs, the second to PyPy envs, which use a simpler path to site-packages. Specifying the actual package name at the end of each of the paths, or changing the order of the tox lines, or explicitly spelling out each tox path rather than using globs, doesn't affect the issue.
If I use the command coverage run -p -m pytest
(parallel mode), then add an extra env at the end to do coverage combine
, I get the correct report, with all tox paths merged into the correct source path. However, if I only want to run one env, like tox -e py36
, then I end up with stray parallel files since the env that runs combine
isn't specified.
Name Stmts Miss Branch BrPart Cover
----------------------------------------------------------------
src/itsdangerous/__init__.py 420 68 98 19 82%
tests/test_itsdangerous.py 233 3 27 0 99%
----------------------------------------------------------------
TOTAL 653 71 125 19 88%
I thought I'd use append mode instead of parallel mode: coverage run -a -m pytest
. This almost works, except the pypy path is always listed separately. The pypy3 path is merged just fine, as are all the CPython paths.
Name Stmts Miss Branch BrPart Cover
------------------------------------------------------------------------------------
.tox/pypy/site-packages/itsdangerous/__init__.py 420 73 98 23 81%
src/itsdangerous/__init__.py 420 68 98 19 82%
tests/test_itsdangerous.py 233 3 27 0 99%
------------------------------------------------------------------------------------
TOTAL 1073 144 223 42 85%
I expected that paths would be appended to a single file in the same way they're combined from parallel files.