13

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

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

示例命令行:

python -m pytest lib_being_tested\tests --cov lib_being_tested.module --cov-report=html
4

2 回答 2

30

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

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

丢失的目录是动态创建的

Simeon 的回答仍然与通过覆盖配置文件选择此输出目录有关

于 2017-12-06T19:08:24.127 回答
11

此配置选项不是pytest-cov.

在默认coverage.py调用的底层工具的配置文件中,您可以添加:.coveragerc

[html]
directory = differentname

有关详细信息,请参阅文档:https ://github.com/nedbat/coveragepy/blob/master/doc/config.rst

于 2014-12-18T00:42:13.540 回答