使用pytests覆盖是一个非常有用的工具。
Html报告允许很好的输出,但是通过命令行,找不到修改默认输出目录的选项(htmlcov)
示例命令行:
python -m pytest lib_being_tested\tests --cov lib_being_tested.module --cov-report=html
答案 0 :(得分:8)
现在(3年后)您可以直接在命令行中更改默认输出目录:
python -m pytest --cov --cov-report=html:reports/html_dir --cov-report=xml:reports/coverage.xml lib_being_tested.module
即时创建缺少的目录
Simeon's answer仍然与通过覆盖配置文件
选择此输出目录相关答案 1 :(得分:5)
此配置选项不属于pytest-cov
。
在基础工具coverage.py
的配置文件中,默认情况下称为.coveragerc
,您可以添加:
[html]
directory = differentname
有关详细信息,请参阅文档:https://github.com/nedbat/coveragepy/blob/master/doc/config.rst