为什么某些 Python 文件没有被coverage.py 检查?

发布于 2024-11-05 17:12:51 字数 189 浏览 0 评论 0原文

我正在使用coverage.py 来测量Python 项目中的测试覆盖率,但某些Python 文件未显示在覆盖率报告中。这些文件的不同之处在于它们没有被任何测试执行(即,如果它们包含在报告中,它们的覆盖率将为 0%)。

未检查这些文件的可能原因有哪些?如果是因为它们在单元测试期间从未加载,是否可以强制coverage.py将这些文件包含在报告中?

I'm using coverage.py to measure test coverage in a Python project, but some Python files are not showing up in the coverage report. One thing that is different about these files is that they were not executed by any tests (i.e., if they were included in the report, their coverage would be 0%).

What are possible reasons why these files were not examined? If it's because they were never loaded during unit testing, is it possible to force coverage.py to include these files in the report?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一城柳絮吹成雪 2024-11-12 17:12:51

如果您的文件在测试会话期间甚至没有加载,它们甚至不会出现在覆盖结果中。但是您可以使用 < 强制coverage.py 测量您想要的每个文件中的“非”覆盖率代码>源选项。它甚至会将未加载的源代码包含到覆盖率报告中。

If your files are even not loaded during your testing session, they won't even appear in coverage result. But you can force coverage.py to measure "non" coverage in every file you want with the source option. It will include even non loaded source code to the coverage report.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文