JetBrains / teamcity-messages

Python Unit Test Reporting to TeamCity
https://pypi.python.org/pypi/teamcity-messages
Apache License 2.0
137 stars 81 forks source link

Pytest coverage statistics reporting fails #218

Closed stefanhartmann123 closed 4 years ago

stefanhartmann123 commented 5 years ago

Running pytest coverage in teamcity with teamcity-messages fails with the following error:

image

Using: teamcity-messages 1.25 pytest-cov 2.7.1

Python version: 3.6.8

enkelli commented 4 years ago

I think this should be fixed in #226 but it already waits more than 1 month for merge :disappointed:

angelomelonas commented 4 years ago

I'm using teamcity-messages 1.28, pytest-cov 2.8.1 and I'm still getting the error above when running pytest.

enkelli commented 4 years ago

I'm using teamcity-messages 1.28, pytest-cov 2.8.1 and I'm still getting the error above when running pytest.

Hi, can you provide more details? Full output with the error message, coverage tool version, etc.?

angelomelonas commented 4 years ago

Hi @enkelli I was just about to add that using the setup above but then setting coverage <5.0 gets rid of the error. I should also note I'm using Python 3.6.9, pytest-5.4.1, sugar-0.9.3 and cov-2.8.1

The error (when using coverage >= 5.0):

Coverage statistics reporting failed
Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pycharm/teamcity/pytest_plugin.py", line 370, in pytest_terminal_summary
    self._report_coverage()
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pycharm/teamcity/pytest_plugin.py", line 377, in _report_coverage
    from coverage.report import Reporter
ImportError: cannot import name 'Reporter'

Edit: my bad, I misread the small text and see now that error I'm seeing and the one above are not the same. It should be post here: https://github.com/JetBrains/teamcity-messages/issues/225

enkelli commented 4 years ago

Are you sure you've got teamcity-messages==1.28? Your log says that line 377 in pytest_plugin contains: from coverage.report import Reporter. But line 377 is actually: from coverage.misc import NotPython.

Check 1.28 source code here - the only import of Reporter class is handled correctly in try-except. I bet there is some older version of teamcity-messages in use.

angelomelonas commented 4 years ago

@enkelli you are correct. It seems the version of teamcity being used is not the one I specifically specify in my Pipfile (which is version 1.28). Checking in /Applications/PyCharm.app/Contents/plugins/python/helpers/pycharm/teamcity/__init__.py I see that indeed it is version 1.26.