Pycharm没有显示覆盖范围,但显示了代码文件中的覆盖范围

发布于 2025-01-28 02:58:49 字数 368 浏览 3 评论 0原文

我正在尝试在Pycharm的“覆盖面板”中查看我们的测试的代码覆盖范围。一切都可以正常工作,文件中出现了代码覆盖范围,但是我似乎无法在覆盖面板中获得任何统计信息。它保持空。我已经尝试删除.Coverage文件,重新启动Pycharm,添加-COV- NO-COV到测试配置的参数。统计数据不显示的原因是什么?

I'm trying to see the code coverage of our test in the coverage panel from pycharm. Everything works as it should, with code coverage appearing in the files, but I can't seem to get any statistics in the coverage panel. It stays empty. I've tried removing the .coverage files, restarting pycharm, adding --cov and --no-cov to the parameters of the test configuration. What can be the reason the statistics don't show up?

Code with coverage on the left, empty statistics on the right

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

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

发布评论

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

评论(1

饮惑 2025-02-04 02:58:49
  1. 如果使用Pycharm按钮运行覆盖范围,则看起来像“带有绿色播放按钮的盾牌” “按钮图标”然后您不使用pytest-covcoverage.pycoverage.py可以通过Pycharm设置(设置>构建,执行,部署> Coverage)进行部分配置。大多数设置必须在.coveragerc文件中设置。
  2. 我设置coverage.py以忽略我的tests目录。
...
omit =
    */tests*
...

覆盖范围视图(问题中图像中右侧的窗格)未显示tests的统计信息 ,但无论如何显示了“测试”中文件的行命中在编辑中。
因此,程序可以成为“省略”。

另一个想法:用代码的目录的名称包含一些不可见的字符,导致错误阻止显示统计信息。

  1. If you are running coverage counting using PyCharm button looking like "shield with green play button" The button icon then you use not pytest-cov but coverage.py. coverage.py can be partly configured by PyCharm settings (Settings>Build, Execution, Deployment>Coverage). Most settings must be set in the .coveragerc file.
  2. I set coverage.py up to ignore my tests directory.
...
omit =
    */tests*
...

Coverage View (the pane on the right on the image in the question) does not show the statistics for tests but anyway the line hit for the files in 'tests' are shown in editor.
So Program can become "omit" for example.

Another idea: the name of the directory with the code contains some not visible characters that causes a bug preventing the statistics from showing.

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