-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
pytest 2.8.1: wrong error type is caught in _pytest/python.py in def _idval(val, argname, idx, idfn) #1099
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
Comments
Similar problem exists in the following function implementation (in _pytest/python.py): def _escape_bytes(val):
"""
In py2 bytes and str are the same, so return it unchanged if it
is a full ascii string, otherwise escape it into its binary form.
"""
try:
return val.encode('ascii')
except UnicodeDecodeError:
return val.encode('string-escape') which may be fixed by replacing |
It seems at least the first case was fixed in #1092 |
@sergiy-kozak could you try with latest
|
I'll give it a try and report here. |
Thanks! 😄 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In function _idval(val, argname, idx, idfn) of mentioned source file next code is present:
In case val variable is unicode value, that contains characters with ordinal > 128, str(val) fails with UnicodeEncodeError, which one would like to catch and fall back to autogenerated parameter id value, like argname1, argname2 etc. The current _idval code causes to the collection time exception, for example
UnicodeEncodeError: 'ascii' codec can't encode characters in position 3-5: ordinal not in range(128)
due to wrong error type being caught. To fix the problem, replace linewith
Environment:
platform linux2 -- Python 2.7.9, pytest-2.8.1, py-1.4.30, pluggy-0.3.1 -- /home/myuser/.virtualenvs/test-env/bin/python
The text was updated successfully, but these errors were encountered: