我试图让pytest运行来处理coveragerc文件。我的.coveragerc文件中的设置未使用,因此我猜该文件根本未使用。
请参阅下面的项目结构和pytest调用!我做错什么了?
项目:
basepath/lib/
basepath/.coveragerc
basepath/test/test_lib
basepath/test/run.py
我从virtualenv调用test/run.py
basepath$ python test/run.py
运行.py
import pytest
pytest.main('test/test_lib -v --cov-report xml --cov lib --cov-config .coveragerc')
我试图将.coveragerc移动到不同的目录中,即lib/、test/、test/test_lib/,但它们都不起作用。
我希望得到一个名为“xxxcoverage”的覆盖率文件,如在.coveragerc中设置的,但是我总是得到默认的覆盖率文件
.覆盖范围
[run]
data_file = xxxcoverage
一遍又一遍地阅读pytest文档……我发现了自己的“错误”:
Here上面写着:
所以我的测试没用,因为.coveragerc中的data_file选项没有任何效果。
我用省略选项进行了测试,结果成功了!
.coveragerc
必须按上述(和预期)放置在基径中相关问题 更多 >
编程相关推荐