Strip tox path from pytest-cov output

74 views Asked by At

When using pytest and pytest-cov with tox. My tox.ini is

[tox]
envlist = py3

[testenv]
deps =
    pytest
    pytest-codeblocks
    pytest-cov
commands =
    pytest {tty:--color=yes} {posargs} --cov=mypackagename

The output will contain the full tox path of the files, e.g.:

---------- coverage: platform linux, python 3.11.1-final-0 -----------
Name                                                                                     Stmts   Miss  Cover
------------------------------------------------------------------------------------------------------------
.tox/py3/lib/python3.11/site-packages/mypackagename/__init__.py                              1      0   100%
------------------------------------------------------------------------------------------------------------
TOTAL                                                                                      678    168    75%

I'm not interested in the prefix .tox/py3/lib/python3.11/site-packages/. Is there any way to remove it from the output?

mypackagename/__init__.py                                 1      0   100%
1

There are 1 answers

0
Yeti On BEST ANSWER

This is expected. tox runs your tests on the installed project, not local code. Coveragepy can remap from installed to local via https://coverage.readthedocs.io/en/7.0.1/config.html#paths. See tox itself https://github.com/tox-dev/tox/blob/main/pyproject.toml#L98