- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试让 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/
我正在尝试尽可能多地移动 .coveragerc 上的 pytest-cov 配置 我需要复制文件中命令行传递的 --cov-report xml 参数。 我尝试使用 [xml] 标签和 output
我正在使用 Python Coverage查看我的单元测试覆盖了多少代码。我想使用一个配置文件来配置一些覆盖率设置,但我找不到它在哪里。它不在 .coverage 所在的同一文件夹中。另外,Windo
我的项目根目录中有一个 .coveragerc 文件。它告诉 coverage.py 省略我项目的迁移目录: [run] omit = *migrations* 当我在命令行运行 coverage.p
我正在使用 nosetests --with-coverage 来测试和查看我的单元测试的代码覆盖率。我测试的类有很多外部依赖项,我在单元测试中模拟了所有这些依赖项。 当我运行 nosetests -
我正在尝试让 pytest 运行以处理 coveragerc 文件。我的 .coveragerc 文件中的设置没有被使用,所以我猜这个文件根本没有被使用。 在下面查看我的项目结构和 pytest 调用
我正在对 python 包进行测试,并尝试使用 pytest 进行测试。 该项目具有以下架构: package_name/ __init__.py file1.py file2.py ... 测试/
如果我在 docker 容器内调用 python3 -mcoverage run ...,我会根据需要获得一个 .coverage 文件。 但是,如果我尝试使用容器外部的 .coverage 文件生成
我是一名优秀的程序员,十分优秀!