pythonpytestcoverage.pycoveralls

Coveralls UnicodeDecodeError


I have the following configuration in tox:

[tox]
envlist = py37

[testenv]
passenv = TRAVIS TRAVIS_*
setenv =
    DEFAULT_FROM = mock_email@mock.com
    DEFAULT_SERVER = mock_server
basepython =
    py37: python3.7
deps =
    -r{toxinidir}/requirements.txt
    -r{toxinidir}/test-requirements.txt
    nose
    pytest
    pytest-cov
sitepackages = False
commands =
    pytest {posargs} --cov
# Add the following line locally to get an HTML report --cov-report html:htmlcov-py37

And the following .coveragerc file:

[run]
branch=True
source=sync2jira/
omit=sync2jira/mailer.py

[report]
fail_under=60

But no matter what (even in Travis) python-coveralls can't seem to send the data to coveralls. I get the following error:

Submitting coverage to coveralls.io...
Traceback (most recent call last):
  File "/Users/sidpremkumar/Documents/Work/Sync2Jira/venv/lib/python3.7/site-packages/coverage/data.py", line 293, in read_file
    self.read_fileobj(f)
  File "/Users/sidpremkumar/Documents/Work/Sync2Jira/venv/lib/python3.7/site-packages/coverage/data.py", line 271, in read_fileobj
    data = self._read_raw_data(file_obj)
  File "/Users/sidpremkumar/Documents/Work/Sync2Jira/venv/lib/python3.7/site-packages/coverage/data.py", line 311, in _read_raw_data
    go_away = file_obj.read(len(cls._GO_AWAY))
  File "/Users/sidpremkumar/Documents/Work/Sync2Jira/venv/bin/../lib/python3.7/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x96 in position 106: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/sidpremkumar/Documents/Work/Sync2Jira/venv/bin/coveralls", line 8, in <module>
    sys.exit(main())
  File "/Users/sidpremkumar/Documents/Work/Sync2Jira/venv/lib/python3.7/site-packages/coveralls/cli.py", line 77, in main
    result = coverallz.wear()
  File "/Users/sidpremkumar/Documents/Work/Sync2Jira/venv/lib/python3.7/site-packages/coveralls/api.py", line 176, in wear
    json_string = self.create_report()
  File "/Users/sidpremkumar/Documents/Work/Sync2Jira/venv/lib/python3.7/site-packages/coveralls/api.py", line 192, in create_report
    data = self.create_data()
  File "/Users/sidpremkumar/Documents/Work/Sync2Jira/venv/lib/python3.7/site-packages/coveralls/api.py", line 246, in create_data
    self._data = {'source_files': self.get_coverage()}
  File "/Users/sidpremkumar/Documents/Work/Sync2Jira/venv/lib/python3.7/site-packages/coveralls/api.py", line 261, in get_coverage
    workman.load()
  File "/Users/sidpremkumar/Documents/Work/Sync2Jira/venv/lib/python3.7/site-packages/coverage/control.py", line 677, in load
    self.data_files.read(self.data)
  File "/Users/sidpremkumar/Documents/Work/Sync2Jira/venv/lib/python3.7/site-packages/coverage/data.py", line 653, in read
    data.read_file(self.filename)
  File "/Users/sidpremkumar/Documents/Work/Sync2Jira/venv/lib/python3.7/site-packages/coverage/data.py", line 297, in read_file
    filename, exc.__class__.__name__, exc,
coverage.misc.CoverageException: Couldn't read data from '/Users/sidpremkumar/Documents/Work/Sync2Jira/.coverage': UnicodeDecodeError: 'utf-8' codec can't decode byte 0x96 in position 106: invalid start byte

Any ideas why I'm getting this error? I've tried with coverage too instead of pytest but no luck.


Solution

  • You may be using a major version of coverage which is incompatible with your version of pytest and/or pytest-cov. Make sure if you're using coverage 5.0, which was just released on December 14th, that you're also using the latest versions of these other modules.

    Can you share your requirements.txt?