Pytest-cov
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
asyncio의 create_subprocess_shell을 사용하면, 개별 테스트는 잘 되는데, 전체 테스트를 돌릴때 다음과 같은 에러가 발생된다.
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 |
정확하진 않다. |
shutil.rmtree() 함수를 두 번 사용하면 발생되더라... 그래서 python에서 shell 관련 함수를 사용하면 영향받는듯 하다... 그냥 추정이다.