代码覆盖率不适用于PyDev [英] Code Coverage not working with PyDev

查看:85
本文介绍了代码覆盖率不适用于PyDev的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,很抱歉再次询问。我找到了有关该主题的一些文章,但是没有任何建议对我有用。结果众所周知:PyDev总是报告文件没有统计信息。

First, sorry for asking again. I found some posts on this topic, but none of the recommendations worked for me. The outcome is well known: PyDev always reports "File has no statistics".

在以前的安装中(Linux和Windows),我看到了 PyDev主页

In a previous installation (Linux and Windows) I saw this working as described in the PyDev homepage.

这是我的安装:


  • Ubuntu 15.10

  • Eclipse Mars.1

  • PyDev 4.4.0.201510052309

  • python 3.4

  • coverage 4.0.3(位于/usr/local/lib/python3.4/dist-packages中)

  • Ubuntu 15.10
  • Eclipse Mars.1
  • PyDev 4.4.0.201510052309
  • python 3.4
  • coverage 4.0.3 (found in /usr/local/lib/python3.4/dist-packages)

在Eclipse / PyDev中,显示了Coverage视图,选择了基本程序文件夹,并选中了为新启动启用代码覆盖率 。每当我运行代码时(无论是进行单元测试还是正常运行),覆盖率窗口都会显示空表,或者,如果选择了文件,则会显示上述消息。

In Eclipse/PyDev the Coverage view is shown, the basic program folder is selected and "enable code coverage for new launches" is checked. Anytime I run the code (no matter if unit tests or normal run) the coverage window shows the empty table or, if a file is selected, the above message.

路径(从/ home / username ...开始)不包含任何空格。

The path (starting from /home/username...) doesn't contain any spaces.

我尝试将PyUnit的详细级别设置为9。尽管控制台有更多功能输出,覆盖范围统计信息仍然为空。

I tried to set PyUnit's verbosity level to 9. Though the console has got more output, the coverage statistics remain empty.

外面还有谁有什么主意吗?在这种情况下,我有错过任何事情吗?

Is anyone out there who has still any idea? Did I miss anything in this scenario?

感谢您的帮助。

Chris

编辑: .coverage文件的路径由详细的PyUnit控制台输出报告。该文件存在,看起来像这样(我刚刚删除了这里的路径,但它是正确的):

The path to the .coverage file is reported by the verbose PyUnit's console output. This file exists, and it looks like this (I just removed the path here, but it was correct):

!coverage.py:这是一种私有格式,请不要不能直接阅读!{ lines:{ /home/.../....py:[5、7、8、9、12、14、15、16、17、18、19, 21,22,25,26,27,29,30,31,32,33,34,35,39,40,42,43], /home/.../....py:[5 ,38、7、29、9、42、11、12、13、15、17、44、19、40、21、23、25、27、10、31], / home /.../。 ..py:[32、33、34、35、36、5、7、8、9、39、12、15、23、26、27、37、30、31]}}

!coverage.py: This is a private format, don't read it directly!{"lines": {"/home/.../....py": [5, 7, 8, 9, 12, 14, 15, 16, 17, 18, 19, 21, 22, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 39, 40, 42, 43], "/home/.../....py": [5, 38, 7, 29, 9, 42, 11, 12, 13, 15, 17, 44, 19, 40, 21, 23, 25, 27, 10, 31], "/home/.../....py": [32, 33, 34, 35, 36, 5, 7, 8, 9, 39, 12, 15, 23, 26, 27, 37, 30, 31]}}

推荐答案

问题是 coverage 的版本,据说该版本必须小于v4。正如用户 saaj 在他对这个问题,安装完成

The problem was the version of coverage, which supposedly must be less than v4. As user saaj wrote in his answer to this question, the installation done with

sudo pip install "coverage < 4.0.0"

解决了该问题。所以这是我的安装:

fixed the problem. So this is my installation:


  • Python 3.4

  • PyDev 4.4

  • 覆盖率3.7.1

,此组合效果很好。

更新:我现在(2019年1月)再次对其进行了检查,可以确认该工具的当前版本可以正常工作:

UPDATE: I now (Jan 2019) checked it again and can confirm, that current versions of the tools work fine together:


  • Python 3.5

  • PyDev 7.0.3

  • 覆盖率4.5.2

因此,不再需要如上所述的特定版本的保险。

So there is no need anymore to call a specific version of coverage as shown above.

这篇关于代码覆盖率不适用于PyDev的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆