gpt4 book ai didi

python - 运行 py.test 时的 .coveragerc 文件位置

转载 作者:太空狗 更新时间:2023-10-29 21:50:42 25 4
gpt4 key购买 nike

我正在尝试让 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 中所设置的那样,但我总是得到默认的 .coverage

.coveragerc

[run]
data_file = xxxcoverage

最佳答案

一遍又一遍地阅读pytest文档……我发现了我的“错误”:
Here它说:

Note that this plugin controls some options and setting the option in the config file will have no effect. These include specifying source to be measured (source option) and all data file handling (data_file and parallel options).

所以我的测试没有用,因为 .coveragerc 中的 data_file 选项没有效果。

我用省略选项进行了测试,它起作用了!

.coveragerc 必须如上所述(和预期的)放置在基本路径中

关于python - 运行 py.test 时的 .coveragerc 文件位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9940702/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com