Python覆盖范围突然掉落

发布于 2025-01-31 21:22:46 字数 472 浏览 5 评论 0原文

我正在使用Pyqt5创作用Python编写的GUI,并且正在为Sonarqube准备报道报告。

覆盖范围最初为43%。然后在我更改主文件后突然下降,称为app.py。我所做的就是添加以下内容:

if __name__ == "__main__":
    main()

我添加了此内容,因为没有它,它会在导入app.py时显示GUI。 main()简单地实例化应用程序,还包含指令显示主窗口。随着上述添加,覆盖范围降至14%。如果我删除上述内容,则覆盖范围将返回到43%。有什么想法为什么添加这种微小的变化后,覆盖范围会突然下降,以及我如何阻止它掉落太多?

版本:

  • Python 3.10.2
  • Coverage.Py,版本6.3.3,带有C扩展
  • Pyqt5 5.15.4

I'm working on a GUI written in Python using PyQt5, and I'm preparing the coverage report for SonarQube.

The coverage was initially 43%. Then it suddenly dropped after I changed the main file, called app.py. All I did was add the following:

if __name__ == "__main__":
    main()

I added this because without it, it would display the GUI when importing app.py.
The main() simply instantiates the application, and also contains instructions to show the main window. With the above addition, the coverage drops to 14%. If I remove the above, the coverage goes right back to 43%. Any ideas why the coverage would suddenly drop significantly upon adding this tiny change, and how I could prevent it from dropping this much?

Versions:

  • Python 3.10.2
  • Coverage.py, version 6.3.3 with C extension
  • PyQt5 5.15.4

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文