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

Plugin changes the default console report under nosetests #216

Open olii opened 5 years ago

olii commented 5 years ago

When I run the test under the vanilla nosetests with the teamcity-messages plugin installed I get the following output:

F
======================================================================
FAIL: test_fails (tests.TestTT)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/user/virtualenv/lib/python3.7/site-packages/teamcity/diff_tools.py", line 32, in _patched_equals
    old(self, first, second, msg)
  File "/usr/lib/python3.7/unittest/case.py", line 839, in assertEqual
    assertion_func(first, second, msg=msg)
  File "/usr/lib/python3.7/unittest/case.py", line 832, in _baseAssertEqual
    raise self.failureException(msg)
AssertionError: 1 != 2

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/tests.py", line 7, in test_fails
    self.assertEqual(1, 2)
  File "/home/user/virtualenv/lib/python3.7/site-packages/teamcity/diff_tools.py", line 38, in _patched_equals
    raise error
teamcity.diff_tools.EqualsAssertionError:  :: 1 != 2

----------------------------------------------------------------------
Ran 1 test in 0.001s

FAILED (failures=1)

When I uninstall the plugin I get the more compact version of the output:

F
======================================================================
FAIL: test_fails (tests.TestTT)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/tests.py", line 7, in test_fails
    self.assertEqual(1, 2)
AssertionError: 1 != 2

----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (failures=1)

I my opinion, when the environment is not set to print a service messages (e.g. TEAMCITY_VERSION is not present in env), the default output should not be altered. Is there any way I can disable it when not running under Teamcity? Or is this intentional?

jklewa commented 2 years ago

I'm running into the same behavior with pytest and found that disabling the teamcity.pytest_plugin module (pytest -p no:pytest-teamcity) removed the teamcity.diff_tools patching.

I agree that this behavior should be based on something like TEAMCITY_VERSION being present in env.