You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When COV_CORE_SRC is a relative directory and a subprocess first changes its working directory
before invoking Python then coverage won't associate the
Expected vs actual result
Get proper coverage reporting, but coverage is not reported properly.
Reproducer
specifiy the test directory with a relative path, i.e. bin/py.test src
Create wrap a subprocess call in a shell script that first changes its work directory before calling bin/python src/something.py
Versions
Output of relevant packages pip list, python --version, pytest --version etc.
Include your tox.ini, pytest.ini, .coveragerc, setup.cfg or any relevant configuration.
[run]
branch = True
[pytest]
addopts = --timeout=30 --tb=native --cov=src --cov-report=html src -r w
markers = slow: This is a non-unit test and thus is not run by default. Use ``-m slow`` to run these, or ``-m 1`` to run all tests.
log_level = NOTSET
filterwarnings =
ignore::DeprecationWarning:telnetlib3.*:
I'm currently working around this by explicitly making COV_CORE_SRC absolute before calling the subprocess. I guess this could/should be done in general, too.
In my experiements, I found that subprocess coverage reporting works better when specifying source packages instead of filesystem paths.
In my case, this wasn't easy using a "flat" repo structure where the package directory (relative to repo root) and the package name are the same string. coverage.py seems to prefer interpreting blah as a filesystem path (if it exists), even if blah might be a package name.
A solution is to explicitly use source_pkgs = in the [coverage:run] section of the config file, and then simply pass --cov to pytest
Summary
When COV_CORE_SRC is a relative directory and a subprocess first changes its working directory
before invoking Python then coverage won't associate the
Expected vs actual result
Get proper coverage reporting, but coverage is not reported properly.
Reproducer
bin/py.test src
bin/python src/something.py
Versions
Output of relevant packages
pip list
,python --version
,pytest --version
etc.Config
Include your
tox.ini
,pytest.ini
,.coveragerc
,setup.cfg
or any relevant configuration.Code
See https://github.com/flyingcircusio/backy/blob/master/src/backy/tests/test_backy.py#L99
I'm currently working around this by explicitly making COV_CORE_SRC absolute before calling the subprocess. I guess this could/should be done in general, too.
The text was updated successfully, but these errors were encountered: