coverage.py 将在其报告中包含 init.py 并将其显示为 0 行,但覆盖率为 100%。
我想从覆盖率报告中排除所有空白文件。我不能只将 */__init__.py
添加到 omit
,因为我的一些 __init__.py
文件有代码。
最佳答案
来自docs和 docs :“5.0 版中的新功能:contexts
和 skip_empty
参数。”在您的 tox.ini
文件或 .coveragerc
文件中添加以下内容:
[coverage:report]
skip_empty = true
"If skip_empty is true, don’t report on empty files (those that have no statements)."
"skip_empty (boolean, default False): Don’t include empty files (those that have 0 statements) in the report. See Coverage summary for more information."
关于python - 忽略覆盖率报告中的空文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20951914/