mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #2158: test_latex_build.test_footnote and some tests fail on Windows environment with py3
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
from codecs import open
|
||||
from io import open
|
||||
|
||||
from six import PY2, text_type
|
||||
|
||||
@@ -126,21 +126,23 @@ class path(text_type):
|
||||
def utime(self, arg):
|
||||
os.utime(self, arg)
|
||||
|
||||
def write_text(self, text, **kwargs):
|
||||
def write_text(self, text, encoding='utf-8', **kwargs):
|
||||
"""
|
||||
Writes the given `text` to the file.
|
||||
"""
|
||||
f = open(self, 'w', **kwargs)
|
||||
if isinstance(text, bytes):
|
||||
text = text.decode(encoding)
|
||||
f = open(self, 'w', encoding=encoding, **kwargs)
|
||||
try:
|
||||
f.write(text)
|
||||
finally:
|
||||
f.close()
|
||||
|
||||
def text(self, **kwargs):
|
||||
def text(self, encoding='utf-8', **kwargs):
|
||||
"""
|
||||
Returns the text in the file.
|
||||
"""
|
||||
f = open(self, mode='U', **kwargs)
|
||||
f = open(self, mode='U', encoding=encoding, **kwargs)
|
||||
try:
|
||||
return f.read()
|
||||
finally:
|
||||
|
||||
@@ -58,12 +58,12 @@ def test_build_all():
|
||||
"""))
|
||||
|
||||
master_doc = srcdir / 'contents.txt'
|
||||
master_doc.write_bytes((master_doc.text() + dedent("""
|
||||
master_doc.write_text(master_doc.text() + dedent(u"""
|
||||
.. toctree::
|
||||
|
||||
%(test_name)s/%(test_name)s
|
||||
""" % {'test_name': test_name})
|
||||
).encode('utf-8'))
|
||||
)
|
||||
|
||||
# note: no 'html' - if it's ok with dirhtml it's ok with html
|
||||
for buildername in ['dirhtml', 'singlehtml', 'latex', 'texinfo', 'pickle',
|
||||
|
||||
Reference in New Issue
Block a user