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

Tests, failed on comparing unicoded values, cause an internal error (instead of Assertion) #1899

Closed
5 tasks done
maxkoryukov opened this issue Sep 1, 2016 · 4 comments
Closed
5 tasks done

Comments

@maxkoryukov
Copy link

maxkoryukov commented Sep 1, 2016

Hello!

In two words: I have failed test (expected), but instead of description of AssertError (I am expecting it), I got Internal PyTest error (unexpected 💥 )

I have one enough complex test, and the last assert instruction compares a string variable with a unicode constant. I have created tiny test, which have the same behavior:

class TestUnicode(object):
    def test_x(self):
        x = u'текст'  # it is russian text
        assert x == u'ПРОСТО РУССКИЙ ТЕКСТ'

This test should tell me, that x have unexpected value, but here is what I got:

myproject/translators/unicode_test.py ...
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "./libs/_pytest/main.py", line 96, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "./libs/_pytest/main.py", line 131, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "./libs/_pytest/vendored_packages/pluggy.py", line 724, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "./libs/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "./libs/_pytest/vendored_packages/pluggy.py", line 333, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "./libs/_pytest/vendored_packages/pluggy.py", line 595, in execute
INTERNALERROR>     return _wrapped_call(hook_impl.function(*args), self.execute)
INTERNALERROR>   File "./libs/_pytest/vendored_packages/pluggy.py", line 249, in _wrapped_call
INTERNALERROR>     wrap_controller.send(call_outcome)
INTERNALERROR>   File "./libs/_pytest/vendored_packages/pluggy.py", line 279, in get_result
INTERNALERROR>     _reraise(*ex)  # noqa
INTERNALERROR>   File "./libs/_pytest/vendored_packages/pluggy.py", line 264, in __init__
INTERNALERROR>     self.result = func()
INTERNALERROR>   File "./libs/_pytest/vendored_packages/pluggy.py", line 596, in execute
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "./libs/_pytest/main.py", line 152, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "./libs/_pytest/vendored_packages/pluggy.py", line 724, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "./libs/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "./libs/_pytest/vendored_packages/pluggy.py", line 333, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "./libs/_pytest/vendored_packages/pluggy.py", line 595, in execute
INTERNALERROR>     return _wrapped_call(hook_impl.function(*args), self.execute)
INTERNALERROR>   File "./libs/_pytest/vendored_packages/pluggy.py", line 253, in _wrapped_call
INTERNALERROR>     return call_outcome.get_result()
INTERNALERROR>   File "./libs/_pytest/vendored_packages/pluggy.py", line 279, in get_result
INTERNALERROR>     _reraise(*ex)  # noqa
INTERNALERROR>   File "./libs/_pytest/vendored_packages/pluggy.py", line 264, in __init__
INTERNALERROR>     self.result = func()
INTERNALERROR>   File "./libs/_pytest/vendored_packages/pluggy.py", line 596, in execute
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "./libs/_pytest/runner.py", line 66, in pytest_runtest_protocol
INTERNALERROR>     runtestprotocol(item, nextitem=nextitem)
INTERNALERROR>   File "./libs/_pytest/runner.py", line 79, in runtestprotocol
INTERNALERROR>     reports.append(call_and_report(item, "call", log))
INTERNALERROR>   File "./libs/_pytest/runner.py", line 133, in call_and_report
INTERNALERROR>     call = call_runtest_hook(item, when, **kwds)
INTERNALERROR>   File "./libs/_pytest/runner.py", line 151, in call_runtest_hook
INTERNALERROR>     return CallInfo(lambda: ihook(item=item, **kwds), when=when)
INTERNALERROR>   File "./libs/_pytest/runner.py", line 168, in __init__
INTERNALERROR>     self.excinfo = ExceptionInfo()
INTERNALERROR>   File "./libs/_pytest/_code/code.py", line 357, in __init__
INTERNALERROR>     exprinfo = str(tup[1])
INTERNALERROR> UnicodeEncodeError: 'ascii' codec can't encode characters in position 8-12: ordinal not in range(128)

My environment

I don't have any specific libs in the environment, just one thing: all libs are installed to the ./libs folder, and it is added to the PYTHONPATH. I think, this have no meaning for this bug..

pytest

user@host ~/myproject $ PYTHONPATH=libs pytest --version
This is pytest version 3.0.1, imported from ~/myproject/libs/pytest.pyc
setuptools registered plugins:
  pytest-cov-2.3.1 at ~/myproject/libs/pytest_cov/plugin.py

os

linux mint 17, 3.19.0-32-generic


  • Include a detailed description of the bug or suggestion
  • pip list of the virtual environment you are using
  • pytest and operating system versions
  • Minimal example if possible
  • fix bug 🍰
@maxkoryukov maxkoryukov changed the title Tests, failed on comparing unicoded values, cause to internal errors (instead of Assertions) Tests, failed on comparing unicoded values, cause an internal error (instead of Assertion) Sep 1, 2016
@nicoddemus
Copy link
Member

Thanks for the report!

Closing as duplicate of #1864. This as been fixed by #1870 and will be available in 3.0.2. 😁

@maxkoryukov
Copy link
Author

@nicoddemus sorry for duplicate(

Search doesn't give me that ticket..

Thanks!

@nicoddemus
Copy link
Member

No worries!

Quick tip: to serach for internal errors with a traceback like this, I usually remove the is:open filter and search for a relevant line of code that appears in the traceback, like this. 😉

@maxkoryukov
Copy link
Author

hm, it looks useful;) thanks!

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

No branches or pull requests

2 participants