使用以下设置,计算出的覆盖率小于使用没有并行化的单线程的覆盖率。 Coverage 仅在项目根目录中创建 1 个覆盖文件,我预计这就是问题所在。
我无法确定我做错了什么,报告的覆盖范围比我简单地运行要少coverage -m pytest
(在单线程上)。测试本身可以并行运行。
谁能指出我的错误吗?我想知道是否缺少环境变量。我从项目根运行命令,其中包含.coveragerc
and sitecustomize.py
.
coverage erase && COVERAGE_PROCESS_START=./.coveragerc coverage run --concurrency=multiprocessing --parallel-mode -m pytest -n 8 && coverage combine && coverage report
网站定制.py
import coverage
coverage.process_startup()
.coveragerc
[run]
include =
lettergun/*
omit =
*migrations*
*tests*
*.html
plugins = django_coverage_plugin
parallel = True
concurrency = multiprocessing
branch = True
pytest.ini
[pytest]
addopts = --ds=config.settings.test --reuse-db -n 8
python_files = test_*.py
norecursedirs = node_modules
DJANGO_SETTINGS_MODULE = config.settings.test
https://github.com/nedbat/coveragepy/issues/1341 https://github.com/nedbat/coveragepy/issues/1341提供了一些上下文(以及可能的解决方案),特别是此评论:https://github.com/nedbat/coveragepy/issues/1341#issuecomment-1302863172 https://github.com/nedbat/coveragepy/issues/1341#issuecomment-1302863172
我尝试添加coverage-enable-subprocess
包但没有让它发挥作用。
我改用pytest-cov
并在使用时得到覆盖率报告pytest-xdist
)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)