New issue 540: Encoding failure in doctest error handling on py3/windows https://bitbucket.org/hpk42/pytest/issue/540/encoding-failure-in-doctest-error-handling
Ionel Maries Cristian: I get this sort of failure: ``` C:\Users\ionel_000\Projects\asdfasdf>tox py34 create: C:\Users\ionel_000\Projects\asdfasdf\.tox\py34 py34 installdeps: pytest py34 runtests: PYTHONHASHSEED='922087378' py34 runtests: commands[0] | py.test -vv ============================= test session starts ============================= platform win32 -- Python 3.4.1 -- py-1.4.20 -- pytest-2.5.2 -- C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\Scripts\python.exe collected 1 items unicode.rst: [doctest] unicode.rst INTERNALERROR> Traceback (most recent call last): INTERNALERROR> File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\main.py", line 81, in wrap_session INTERNALERROR> doit(config, session) INTERNALERROR> File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\main.py", line 118, in _main INTERNALERROR> config.hook.pytest_runtestloop(session=session) INTERNALERROR> File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\core.py", line 377, in __call__ INTERNALERROR> return self._docall(methods, kwargs) INTERNALERROR> File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\core.py", line 388, in _docall INTERNALERROR> res = mc.execute() INTERNALERROR> File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\core.py", line 289, in execute INTERNALERROR> res = method(**kwargs) INTERNALERROR> File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\main.py", line 138, in pytest_runtestloop INTERNALERROR> item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem) INTERNALERROR> File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\core.py", line 377, in __call__ INTERNALERROR> return self._docall(methods, kwargs) INTERNALERROR> File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\core.py", line 388, in _docall INTERNALERROR> res = mc.execute() INTERNALERROR> File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\core.py", line 289, in execute INTERNALERROR> res = method(**kwargs) INTERNALERROR> File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\runner.py", line 64, in pytest_runtest_protocol INTERNALERROR> runtestprotocol(item, nextitem=nextitem) INTERNALERROR> File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\runner.py", line 74, in runtestprotocol INTERNALERROR> reports.append(call_and_report(item, "call", log)) INTERNALERROR> File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\runner.py", line 110, in call_and_report INTERNALERROR> report = hook.pytest_runtest_makereport(item=item, call=call) INTERNALERROR> File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\main.py", line 162, in call_matching_hooks INTERNALERROR> return hookmethod.pcall(plugins, **kwargs) INTERNALERROR> File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\core.py", line 381, in pcall INTERNALERROR> return self._docall(methods, kwargs) INTERNALERROR> File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\core.py", line 388, in _docall INTERNALERROR> res = mc.execute() INTERNALERROR> File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\core.py", line 289, in execute INTERNALERROR> res = method(**kwargs) INTERNALERROR> File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\capture.py", line 246, in pytest_runtest_makereport INTERNALERROR> rep = __multicall__.execute() INTERNALERROR> File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\core.py", line 289, in execute INTERNALERROR> res = method(**kwargs) INTERNALERROR> File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\runner.py", line 208, in pytest_runtest_makereport INTERNALERROR> longrepr = item.repr_failure(excinfo) INTERNALERROR> File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\_pytest\doctest.py", line 61, in repr_failure INTERNALERROR> filelines = py.path.local(filename).readlines(cr=0) INTERNALERROR> File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\py\_path\common.py", line 134, in readlines INTERNALERROR> content = self.read('rU') INTERNALERROR> File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\site-packages\py\_path\common.py", line 126, in read INTERNALERROR> return f.read() INTERNALERROR> File "C:\Users\ionel_000\Projects\asdfasdf\.tox\py34\lib\encodings\cp1250.py", line 23, in decode INTERNALERROR> return codecs.charmap_decode(input,self.errors,decoding_table)[0] INTERNALERROR> UnicodeDecodeError: 'charmap' codec can't decode byte 0x83 in position 8: character maps to <undefined> ============================== in 0.05 seconds =============================== ERROR: InvocationError: 'C:\\Users\\ionel_000\\Projects\\asdfasdf\\.tox\\py34\\Scripts\\py.test.EXE -vv' ___________________________________ summary ___________________________________ ERROR: py34: commands failed ``` Testcase: https://gist.github.com/ionelmc/4a56e2467aeb6d228ebe This fails because the unicode.rst file is utf8 while the windows' default encoding is some code page. Also tested with tip from py/pytest - still reproduces. I've glossed over the code but the fix involves adding "encoding awareness" all over in the `py` module. What to do ? _______________________________________________ pytest-commit mailing list pytest-commit@python.org https://mail.python.org/mailman/listinfo/pytest-commit