python-coveralls icon indicating copy to clipboard operation
python-coveralls copied to clipboard

Breaks with coverage 5.0

Open skwashd opened this issue 5 years ago • 10 comments

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)

skwashd avatar Dec 17 '19 11:12 skwashd

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 ?

madmath03 avatar Jan 09 '20 10:01 madmath03

Any news on supporting coverage>=5?

hartwork avatar Jan 21 '20 22:01 hartwork

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

Wolfe1 avatar Jan 22 '20 19:01 Wolfe1

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

Choi-Sung-Hoon avatar Feb 06 '20 06:02 Choi-Sung-Hoon

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

drewdogg avatar Apr 18 '20 00:04 drewdogg

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

amykyta3 avatar Aug 31 '20 02:08 amykyta3

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

DevGlitch avatar Sep 06 '20 05:09 DevGlitch

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.

wumpus avatar Sep 06 '20 05:09 wumpus

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

DevGlitch avatar Sep 06 '20 06:09 DevGlitch

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.

wumpus avatar Sep 06 '20 06:09 wumpus