[pytest] 使用pytest-cov计算覆盖率
配置.coveragerc
排除某些你不关注的行, 比如 '__main__' 所在行
可以通过配置你本地的 .coveragerc 文件进行设置
[run]
branch = True
omit =
# 计算覆盖率时排除某些文件
*/test_*.py
*/*_test.py
[report]
# 设置报告精度
precision = 2
# 设置报告排除的行
exclude_lines =
# Don't complain about missing debug-only code:
if __name__ == .__main__.:
[html]
# 设置html报告的文件夹
directory = coverage_html_report

浙公网安备 33010602011771号