Merge pull request #3584 from jwodder/fix-3583
Fix encoding error with `print` statements in doctests
This commit is contained in:
commit
2925f3057f
|
@ -0,0 +1 @@
|
||||||
|
Fix encoding error with `print` statements in doctests
|
|
@ -505,7 +505,7 @@ def _fix_spoof_python2(runner, encoding):
|
||||||
|
|
||||||
def getvalue(self):
|
def getvalue(self):
|
||||||
result = _SpoofOut.getvalue(self)
|
result = _SpoofOut.getvalue(self)
|
||||||
if encoding:
|
if encoding and isinstance(result, bytes):
|
||||||
result = result.decode(encoding)
|
result = result.decode(encoding)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
|
@ -655,6 +655,22 @@ class TestDoctests(object):
|
||||||
result = testdir.runpytest(p, "--doctest-modules")
|
result = testdir.runpytest(p, "--doctest-modules")
|
||||||
result.stdout.fnmatch_lines(["* 1 passed *"])
|
result.stdout.fnmatch_lines(["* 1 passed *"])
|
||||||
|
|
||||||
|
def test_print_unicode_value(self, testdir):
|
||||||
|
"""
|
||||||
|
Test case for issue 3583: Printing Unicode in doctest under Python 2.7
|
||||||
|
doesn't work
|
||||||
|
"""
|
||||||
|
p = testdir.maketxtfile(
|
||||||
|
test_print_unicode_value=r"""
|
||||||
|
Here is a doctest::
|
||||||
|
|
||||||
|
>>> print(u'\xE5\xE9\xEE\xF8\xFC')
|
||||||
|
åéîøü
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
result = testdir.runpytest(p)
|
||||||
|
result.stdout.fnmatch_lines(["* 1 passed *"])
|
||||||
|
|
||||||
def test_reportinfo(self, testdir):
|
def test_reportinfo(self, testdir):
|
||||||
"""
|
"""
|
||||||
Test case to make sure that DoctestItem.reportinfo() returns lineno.
|
Test case to make sure that DoctestItem.reportinfo() returns lineno.
|
||||||
|
|
Loading…
Reference in New Issue