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

New version can't work with unicode symbols in test case name #192

Open TimurNurlygayanov opened 6 years ago

TimurNurlygayanov commented 6 years ago

It is regression issue. Issue not reproduced on version 1.21, but reproduced with the latest version.

Steps To Reproduce: 1) Install latest version of teamcity-messages by pip 2) Run test with unicode symbols in test name (example - unicode parameter for PyTest test case will be included in test case name)

Expected Result: All works fine.

Actual Result: Tests failed with traceback:

[06:12:22]INTERNALERROR> File "/var/lib/buildagent/work/b174579a3751dcf0/env/lib/python3.4/site-packages/pluggy/manager.py", line 61, in <lambda> [06:12:22]INTERNALERROR> firstresult=hook.spec_opts.get('firstresult'), [06:12:22]INTERNALERROR> File "/var/lib/buildagent/work/b174579a3751dcf0/env/lib/python3.4/site-packages/pluggy/callers.py", line 201, in _multicall [06:12:22]INTERNALERROR> return outcome.get_result() [06:12:22]INTERNALERROR> File "/var/lib/buildagent/work/b174579a3751dcf0/env/lib/python3.4/site-packages/pluggy/callers.py", line 76, in get_result [06:12:22]INTERNALERROR> raise ex[1].with_traceback(ex[2]) [06:12:22]INTERNALERROR> File "/var/lib/buildagent/work/b174579a3751dcf0/env/lib/python3.4/site-packages/pluggy/callers.py", line 180, in _multicall [06:12:22]INTERNALERROR> res = hook_impl.function(*args) [06:12:22]INTERNALERROR> File "/var/lib/buildagent/work/b174579a3751dcf0/env/lib/python3.4/site-packages/teamcity/pytest_plugin.py", line 205, in pytest_runtest_logreport [06:12:22]INTERNALERROR> self.report_test_output(report, test_id) [06:12:22]INTERNALERROR> File "/var/lib/buildagent/work/b174579a3751dcf0/env/lib/python3.4/site-packages/teamcity/pytest_plugin.py", line 153, in report_test_output [06:12:22]INTERNALERROR> self.teamcity.testStdOut(test_id, out=chunk, flowId=test_id) [06:12:22]INTERNALERROR> File "/var/lib/buildagent/work/b174579a3751dcf0/env/lib/python3.4/site-packages/teamcity/messages.py", line 131, in testStdOut [06:12:22]INTERNALERROR> self.message('testStdOut', name=testName, out=out, flowId=flowId) [06:12:22]INTERNALERROR> File "/var/lib/buildagent/work/b174579a3751dcf0/env/lib/python3.4/site-packages/teamcity/messages.py", line 68, in message [06:12:22]INTERNALERROR> self.output.write(self.encode(message)) [06:12:22]INTERNALERROR> File "/var/lib/buildagent/work/b174579a3751dcf0/env/lib/python3.4/site-packages/teamcity/messages.py", line 39, in encode [06:12:22]INTERNALERROR> value = value.encode(self.encoding) [06:12:22]INTERNALERROR> UnicodeEncodeError: 'ascii' codec can't encode characters in position 693-713: ordinal not in range(128) [06:12:22]Process exited with code 3

TimurNurlygayanov commented 6 years ago

Here is the workaround for the issue: need to hadcode version of the plugin in requirements.txt:

teamcity-messages==1.21

TimurNurlygayanov commented 5 years ago

I've found the workaround!!!

Just add the following line into the beginning of all files with tests:

# -*- coding: utf-8 -*-

TimurNurlygayanov commented 5 years ago

how it also can be fixed:

in file env/lib/python3.4/site-packages/teamcity/messages.py set utf8 by default:

class TeamcityServiceMessages(object):
    def __init__(self, output=sys.stdout, now=datetime.datetime.now, encoding='utf-8'):