z4r / python-coveralls

Python API for http://coveralls.io
Other
224 stars 80 forks source link

Breaks with coverage 5.0 #73

Open skwashd opened 4 years ago

skwashd commented 4 years ago

The 5.0 release of the coverage package contains backwards compatibility breaking changes. One of those changes was removing the Reporter class. This results in the following output in Travis CI:

$ coveralls
Traceback (most recent call last):
  File "/home/travis/virtualenv/python3.7.1/bin/coveralls", line 10, in <module>
    sys.exit(wear())
  File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/coveralls/__init__.py", line 78, in wear
    from coveralls.control import coveralls
  File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/coveralls/control.py", line 2, in <module>
    from coveralls.report import CoverallsReporter
  File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/coveralls/report.py", line 6, in <module>
    from coverage.report import Reporter
ImportError: cannot import name 'Reporter' from 'coverage.report' (/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/coverage/report.py)
madmath03 commented 4 years ago

For info, I have this issue too with Frappe apps (frappe/frappe#9169), but after pinning coverage version to 4.5.4 I have a new error :

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x96 in position 106: invalid start byte

The source code analyzed has not changed and, of course, I did not had this error before. I saw #31 and #30 but the solution does not apply in my case. Maybe it's not related, but has anyone encountered this and found a solution ?

hartwork commented 4 years ago

Any news on supporting coverage>=5?

Wolfe1 commented 4 years ago

@hartwork unless there is something you specifically need here, this worked for me: https://github.com/coveralls-clients/coveralls-python

Choi-Sung-Hoon commented 4 years ago

If you are having a trouble with Travis CI, have a look at #74.

drewdogg commented 4 years ago

@madmath03 That error is due to the outputted .coverage file format is different for coverage 5.0+. The fix is to downgrade coverage and re-run your test suite, which will regenerate that file in the older format that can be read by the coveralls command.

amykyta3 commented 4 years ago

Commenting here since this thread shows up in Google searches often.

There's no need to pin to an older version of coveralls. Instead, make sure you are not installing coverage or python-coveralls as they seem to cause some sort of conflict (See: #73).

This combination is working for me:

pip install -U pytest pytest-cov coveralls
DevGlitch commented 4 years ago

@amykyta3 I tried this as I had the same issue but it didn't solve it.

wumpus commented 4 years ago

I use coverage for coverage report -m, and I use coveralls for coveralls. Are you saying that it's no big deal that they are incompatible? I suppose I could carefully use only one or the other depending on the circumstances. Normally the tools I use aren't this finicky.

DevGlitch commented 4 years ago

I downgraded coverage to a version < 5 and it solved this issue.

wumpus commented 4 years ago

Yes, see the title of the bug and numerous comments above: the problem starts with coverage version 5.

Looking at setup.py for this package, it imports "coverage" without any version.