summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorFernando Macedo <fgmacedo@gmail.com>2017-08-30 16:06:12 -0300
committerFernando Macedo <fgmacedo@gmail.com>2017-08-30 16:06:12 -0300
commit59cdef92beebc9054a1c366afc27e079116af1b6 (patch)
treec50fa61647721e4b61c66ea19540a4322fe7e9cc /testing
parent539523cfee4c49a765569abcf68134b1255eedb5 (diff)
downloadpytest-59cdef92beebc9054a1c366afc27e079116af1b6.tar.gz
fixes #2731 ReprFuncArgs with mixed unicode and utf-8 args
Diffstat (limited to 'testing')
-rw-r--r--testing/code/test_code.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/testing/code/test_code.py b/testing/code/test_code.py
index 6db5c6fbd..209a8ef19 100644
--- a/testing/code/test_code.py
+++ b/testing/code/test_code.py
@@ -1,9 +1,11 @@
+# coding: utf-8
from __future__ import absolute_import, division, print_function
import sys
import _pytest._code
import py
import pytest
+from test_excinfo import TWMock
def test_ne():
@@ -172,3 +174,23 @@ class TestTracebackEntry(object):
source = entry.getsource()
assert len(source) == 6
assert 'assert False' in source[5]
+
+
+class TestReprFuncArgs(object):
+
+ def test_not_raise_exception_with_mixed_encoding(self):
+ from _pytest._code.code import ReprFuncArgs
+
+ tw = TWMock()
+
+ args = [
+ ('unicode_string', u"São Paulo"),
+ ('utf8_string', 'S\xc3\xa3o Paulo'),
+ ]
+
+ r = ReprFuncArgs(args)
+ r.toterminal(tw)
+ if sys.version_info[0] >= 3:
+ assert tw.lines[0] == 'unicode_string = São Paulo, utf8_string = São Paulo'
+ else:
+ assert tw.lines[0] == 'unicode_string = São Paulo, utf8_string = São Paulo'