2

我在 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

以及以下.coveragerc文件:

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

[report]
fail_under=60

但无论如何(即使在 Travis 中)python-coveralls 似乎都无法将数据发送到工作服。我收到以下错误:

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

任何想法为什么我会收到此错误?我也尝试coverage过,pytest但没有运气。

4

2 回答 2

2

您可能正在使用coverage与您的版本不兼容的主要版本pytest和/或pytest-cov. 如果您使用coverage 5.0的是 12 月 14 日刚刚发布的 ,请确保您也在使用这些其他模块的最新版本。

你能分享你的requirements.txt吗?

于 2020-01-02T19:06:49.890 回答
0

在我的情况下,删除.tox项目的隐藏文件夹并重新运行tox有效。

我看到:

report installed: coverage==4.5.4

我现在看到:

report installed: coverage==5.0.3
于 2020-01-22T23:23:46.120 回答