New issue 429: Assert interpretation chokes on mojibake (Python 2.7)
https://bitbucket.org/hpk42/pytest/issue/429/assert-interpretation-chokes-on-mojibake

Ronan Lamy:

Self-explanatory, I hope.

AIUI, the line that fails is doing u''.join([<str>, <str>]) which can only end 
in tears.

```
#!
$ py.test test_mojibake.py --pdb
========================================================================================================
 test session starts 
========================================================================================================
platform linux2 -- Python 2.7.4 -- pytest-2.5.1
plugins: cov
collected 1 items 

test_mojibake.py F
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  traceback 
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    def test_test():
>       assert 'e' == '\xc3\xa9'

test_mojibake.py:2: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

ops = ('==',), results = (False,), expls = ('%(py1)s == %(py4)s',), each_obj = 
('e', '\xc3\xa9')

    def _call_reprcompare(ops, results, expls, each_obj):
        for i, res, expl in zip(range(len(ops)), results, expls):
            try:
                done = not res
            except Exception:
                done = True
            if done:
                break
        if util._reprcompare is not None:
>           custom = util._reprcompare(ops[i], each_obj[i], each_obj[i + 1])

../../.virtualenvs/hippy/local/lib/python2.7/site-packages/_pytest/assertion/rewrite.py:343:
 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

op = '==', left = 'e', right = '\xc3\xa9'

    def callbinrepr(op, left, right):
        hook_result = item.ihook.pytest_assertrepr_compare(
            config=item.config, op=op, left=left, right=right)
    
        for new_expl in hook_result:
            if new_expl:
                # Don't include pageloads of data unless we are very
                # verbose (-vv)
>               if (len(py.builtin._totext('').join(new_expl[1:])) > 80*8
                        and item.config.option.verbose < 2):
E                       UnicodeDecodeError: 'ascii' codec can't decode byte 
0xc3 in position 2: ordinal not in range(128)

../../.virtualenvs/hippy/local/lib/python2.7/site-packages/_pytest/assertion/__init__.py:83:
 UnicodeDecodeError
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  entering PDB 
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> /home/ronan/.virtualenvs/hippy/local/lib/python2.7/site-packages/_pytest/assertion/__init__.py(83)callbinrepr()
-> if (len(py.builtin._totext('').join(new_expl[1:])) > 80*8
(Pdb) p new_expl
[u"'e' == '\\xc3\\xa9'", '- e', '+ \xc3\xa9']
```


_______________________________________________
pytest-commit mailing list
pytest-commit@python.org
https://mail.python.org/mailman/listinfo/pytest-commit

Reply via email to