mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
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:
parent
39e403b8ac
commit
e85ea7ed83
1
CHANGES
1
CHANGES
@ -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)
|
||||
====================================
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user