Code Coverage not working with PyDev

2019-08-11 17:26发布

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".

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

This is my installation:

  • 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)

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.

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

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?

Thanks for your help.

Chris

EDIT: 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: 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]}}

1条回答
Evening l夕情丶
2楼-- · 2019-08-11 17:35

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
  • coverage 3.7.1

and this combination works fine.

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
  • coverage 4.5.2

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

查看更多
登录 后发表回答