Skip to content
Search

Pytest-cov

lastmod 2025-02-14created 2020-12-147 edits

This plugin produces coverage reports.

Reporting

with tox

[tox]
envlist = clean,py27,py36,report

[testenv]
commands = pytest --cov --cov-append --cov-report=term-missing
deps =
    pytest
    pytest-cov
depends =
    {py27,py36}: clean
    report: py27,py36

[testenv:report]
deps = coverage
skip_install = true
commands =
    coverage report
    coverage html

[testenv:clean]
deps = coverage
skip_install = true
commands = coverage erase

Troubleshooting

pytest-cov: Failed to setup subprocess coverage

When using create_subprocess_shell from asyncio, individual tests pass, but the following error occurs when running the full test suite.

E           recc.exception.recc_error.ReccAbnormalTerminationError: pip -m error: code=1,stderr=pytest-cov: Failed to setup subprocess coverage. Environ: {'COV_CORE_SOURCE': ':', 'COV_CORE_CONFIG': '/Users/your/Project/answer-dev/core/pytest.ini', 'COV_CORE_DATAFILE': '/Users/your/Project/answer-dev/core/build/cov/data'} Exception: FileNotFoundError(2, 'No such file or directory') pytest-cov: Failed to setup subprocess coverage. Environ: {'COV_CORE_SOURCE': ':', 'COV_CORE_CONFIG': '/Users/your/Project/answer-dev/core/pytest.ini', 'COV_CORE_DATAFILE': '/Users/your/Project/answer-dev/core/build/cov/data'} Exception: FileNotFoundError(2, 'No such file or directory') Traceback (most recent call last): File "/Users/your/.pyenv/versions/3.8.9/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/Users/your/.pyenv/versions/3.8.9/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/Users/your/.pyenv/versions/3.8.9/envs/opy-your-3.8.9/lib/python3.8/site-packages/pip/__main__.py", line 9, in <module> if sys.path[0] in ("", os.getcwd()): FileNotFoundError: [Errno 2] No such file or directory

WARNING

Not certain.

It seems to happen when the shutil.rmtree() function is used twice... So using shell-related functions in python seems to affect it... Just a guess.

See also

Favorite site

author Zer0 sitemap