Fix decoding issue while formatting SyntaxErrors during collection

This happens only in Python 2, as in Python 3 we receive
the "badline" in the exception is already properly encoded

Fix #578
This commit is contained in:
Bruno Oliveira
2016-03-05 16:58:44 -03:00
parent 3884398055
commit d8403d793f
4 changed files with 42 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import sys
from textwrap import dedent
@@ -1181,3 +1182,19 @@ def test_class_injection_does_not_break_collection(testdir):
result = testdir.runpytest()
assert "RuntimeError: dictionary changed size during iteration" not in result.stdout.str()
result.stdout.fnmatch_lines(['*1 passed*'])
def test_syntax_error_with_non_ascii_chars(testdir):
"""Fix decoding issue while formatting SyntaxErrors during collection (#578)
"""
testdir.makepyfile(u"""
# -*- coding: UTF-8 -*-
""")
result = testdir.runpytest()
result.stdout.fnmatch_lines([
'*ERROR collecting*',
'*SyntaxError*',
'*1 error in*',
])