Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用pytest为覆盖率报告设置不同的html输出目录?_Python_Pytest_Coverage.py - Fatal编程技术网

Python 如何使用pytest为覆盖率报告设置不同的html输出目录?

Python 如何使用pytest为覆盖率报告设置不同的html输出目录?,python,pytest,coverage.py,Python,Pytest,Coverage.py,使用pytests的覆盖率是一个非常有用的工具 Html报告允许良好的输出,但是通过命令行,无法找到修改默认输出目录(htmlcov)的选项 命令行示例: python -m pytest lib_being_tested\tests --cov lib_being_tested.module --cov-report=html python -m pytest --cov --cov-report=html:reports/html_dir --cov-report=xml:reports/

使用pytests的覆盖率是一个非常有用的工具

Html报告允许良好的输出,但是通过命令行,无法找到修改默认输出目录(htmlcov)的选项

命令行示例:

python -m pytest lib_being_tested\tests --cov lib_being_tested.module --cov-report=html
python -m pytest --cov --cov-report=html:reports/html_dir --cov-report=xml:reports/coverage.xml lib_being_tested.module

此配置选项不是
pytest-cov
的一部分

在基础工具
coverage.py
的配置文件中,默认情况下称为
.coveragerc
,您可以添加:

[html]
directory = differentname
有关详细信息,请参阅文档:

现在(3年后),您可以直接在命令行中更改默认输出目录:

python -m pytest lib_being_tested\tests --cov lib_being_tested.module --cov-report=html
python -m pytest --cov --cov-report=html:reports/html_dir --cov-report=xml:reports/coverage.xml lib_being_tested.module
缺少的目录是动态创建的


仍然可以通过覆盖率配置文件选择此输出目录

文档也可以在其规范位置获得: