Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeEncodeError with failing test on Python 2 #500

Closed
blueyed opened this issue Nov 11, 2015 · 2 comments
Closed

UnicodeEncodeError with failing test on Python 2 #500

blueyed opened this issue Nov 11, 2015 · 2 comments
Labels

Comments

@blueyed
Copy link
Collaborator

blueyed commented Nov 11, 2015

==================================== test session starts =====================================
platform linux2 -- Python 2.7.10, pytest-2.8.2, py-1.4.30, pluggy-0.3.1
rootdir: …/vim/neobundles/jedi, inifile: pytest.ini
collected 7 items 

test_integration.py .....F.

========================================== FAILURES ==========================================
__________________________________ test_integration[case5] ___________________________________

case = <<class 'conftest.IntegrationTestFile'>: test/signatures.vim>
monkeypatch = <_pytest.monkeypatch.monkeypatch instance at 0x7f4d8f2673f8>
pytestconfig = <_pytest.config.Config object at 0x7f4d94426f50>

    def test_integration(case, monkeypatch, pytestconfig):
>       case.run()

test_integration.py:2: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <<class 'conftest.IntegrationTestFile'>: test/signatures.vim>

    def run(self):
        output = subprocess.check_output(
            [VSPEC_RUNNER, '.', VSPEC_FOLDER, self.path])
        for line in output.splitlines():
            if line.startswith(b'not ok') or line.startswith(b'Error'):
                pytest.fail("{} failed:\n{}".format(
>                   self.path, output.decode('utf-8')), pytrace=False)
E               UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026' in position 2041: ordinal not in range(128)

conftest.py:25: UnicodeEncodeError
============================= 1 failed, 6 passed in 1.64 seconds =============================

I have tried to fix it like this:

diff --git i/conftest.py w/conftest.py
index 2f844fd..ca87ccf 100644
--- i/conftest.py
+++ w/conftest.py
@@ -21,7 +21,7 @@ def run(self):
             [VSPEC_RUNNER, '.', VSPEC_FOLDER, self.path])
         for line in output.splitlines():
             if line.startswith(b'not ok') or line.startswith(b'Error'):
-                pytest.fail("{} failed:\n{}".format(
+                pytest.fail(u"{} failed:\n{}".format(
                     self.path, output.decode('utf-8')), pytrace=False)

     def __repr__(self):

But that then results in an internal error with py.test:

INTERNALERROR>   File "…/pyenv/2.7.10/envs/jedi-vim2/lib/python2.7/site-packages/_pytest/runner.py", line 224, in pytest_runtest_makereport
INTERNALERROR>     longrepr = item.repr_failure(excinfo)
INTERNALERROR>   File "…/pyenv/2.7.10/envs/jedi-vim2/lib/python2.7/site-packages/_pytest/python.py", line 732, in repr_failure
INTERNALERROR>     return self._repr_failure_py(excinfo, style=style)
INTERNALERROR>   File "…/pyenv/2.7.10/envs/jedi-vim2/lib/python2.7/site-packages/_pytest/python.py", line 723, in _repr_failure_py
INTERNALERROR>     return str(excinfo.value)
INTERNALERROR>   File "…/pyenv/2.7.10/envs/jedi-vim2/lib/python2.7/site-packages/_pytest/runner.py", line 433, in __repr__
INTERNALERROR>     return str(self.msg)
INTERNALERROR> UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026' in position 2069: ordinal not in range(128)

Via #499 (comment).

@blueyed
Copy link
Collaborator Author

blueyed commented Nov 11, 2015

Submitted for pytest at pytest-dev/pytest#1178.

@davidhalter
Copy link
Owner

It was fixed, yay at pytest devs :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants