You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@impala.apache.org by "Quanlong Huang (Jira)" <ji...@apache.org> on 2021/01/04 03:00:00 UTC

[jira] [Created] (IMPALA-10419) pytest hits UnicodeDecodeError in reporting assert failures for UTF-8 results

Quanlong Huang created IMPALA-10419:
---------------------------------------

             Summary: pytest hits UnicodeDecodeError in reporting assert failures for UTF-8 results
                 Key: IMPALA-10419
                 URL: https://issues.apache.org/jira/browse/IMPALA-10419
             Project: IMPALA
          Issue Type: Bug
            Reporter: Quanlong Huang


When the result contains non-ascii bytes, pytest fails to report assertion failures:
{code:java}
tests/query_test/test_exprs.py:71: in test_special_strings
    self.run_test_case('QueryTest/special-strings', vector)
tests/common/impala_test_suite.py:693: in run_test_case
    self.__verify_results_and_errors(vector, test_section, result, use_db)
tests/common/impala_test_suite.py:529: in __verify_results_and_errors
    replace_filenames_with_placeholder)
tests/common/test_result_verifier.py:465: in verify_raw_results
    VERIFIER_MAP[verifier](expected, actual)
infra/python/env-gcc7.5.0/lib/python2.7/site-packages/_pytest/assertion/reinterpret.py:46: in __init__
    self.msg = reinterpret(source, f, should_fail=True)
infra/python/env-gcc7.5.0/lib/python2.7/site-packages/_pytest/assertion/reinterpret.py:96: in reinterpret
    visitor.visit(mod)
toolchain/toolchain-packages-gcc7.5.0/python-2.7.16/lib/python2.7/ast.py:241: in visit
    return visitor(node)
infra/python/env-gcc7.5.0/lib/python2.7/site-packages/_pytest/assertion/reinterpret.py:191: in visit_Module
    self.visit(stmt)
toolchain/toolchain-packages-gcc7.5.0/python-2.7.16/lib/python2.7/ast.py:241: in visit
    return visitor(node)
infra/python/env-gcc7.5.0/lib/python2.7/site-packages/_pytest/assertion/reinterpret.py:383: in visit_Assert
    test_explanation, test_result = self.visit(assrt.test)
toolchain/toolchain-packages-gcc7.5.0/python-2.7.16/lib/python2.7/ast.py:241: in visit
    return visitor(node)
infra/python/env-gcc7.5.0/lib/python2.7/site-packages/_pytest/assertion/reinterpret.py:232: in visit_Compare
    res = util._reprcompare(op_symbol, left_result, next_result)
infra/python/env-gcc7.5.0/lib/python2.7/site-packages/_pytest/assertion/__init__.py:132: in callbinrepr
    res = py.builtin._totext("\n~").join(new_expl)
E   UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 1: ordinal not in range(128){code}
I can manually fix this by modifying infra/python/env-gcc7.5.0/lib/python2.7/site-packages/_pytest/assertion/__init__.py:131 by explicitly specifiying 'utf-8' as the decode encoding.
{code:java}
-                 new_expl = [line.replace("\n", "\\n") for line in new_expl]
+                 new_expl = [line.replace("\n", "\\n").decode('utf-8') for line in new_expl]
                 res = py.builtin._totext("\n~").join(new_expl){code}
Some versions of my env: Python 2.7.16, pytest-2.9.2, py-1.4.32, pluggy-0.3.1. We may need to bump pytest version for a fix.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)