Fix #2062: Escape characters in doctests are treated incorrectly with Python 2

In my current environment with Win10+Py2.7.10, SpoofOut result string doesn't necessary to decode. This commit might cause regression in older python versions....
This commit is contained in:
shimizukawa 2016-01-09 17:22:30 +09:00
parent 39e403b8ac
commit e85ea7ed83
3 changed files with 12 additions and 13 deletions

View File

@ -44,6 +44,7 @@ Bugs fixed
* #2160: Fix broken TOC of PDFs if section includes an image
* #2172: Fix dysfunctional admonition \py@lightbox in sphinx.sty. Thanks to jfbu.
* #2198,#2205: ``make gettext`` generate broken msgid for definition lists.
* #2062: Escape characters in doctests are treated incorrectly with Python 2.
Release 1.3.3 (released Dec 2, 2015)
====================================

View File

@ -45,14 +45,6 @@ else:
return text
class _SpoofOutSphinx(doctest._SpoofOut):
# override: convert console encoding to unicode
if PY2:
def getvalue(self):
result = doctest._SpoofOut.getvalue(self)
return result.decode('string_escape')
# set up the necessary directives
class TestDirective(Directive):
@ -184,11 +176,6 @@ class TestCode(object):
class SphinxDocTestRunner(doctest.DocTestRunner):
def __init__(self, *args, **kw):
doctest.DocTestRunner.__init__(self, *args, **kw)
# Override a fake output target for capturing doctest output.
self._fakeout = _SpoofOutSphinx()
def summarize(self, out, verbose=None):
string_io = StringIO()
old_stdout = sys.stdout

View File

@ -136,3 +136,14 @@ umlauts: äöü.
>>> print('Japanese: 日本語')
Japanese: 日本語
keep control char in raw string
-------------------------------
.. doctest::
>>> print('one\ntwo')
one
two
>>> print(r'one\ntwo')
one\ntwo