summaryrefslogtreecommitdiff
path: root/tests/path.py
diff options
context:
space:
mode:
authorshimizukawa <shimizukawa@gmail.com>2015-12-19 18:57:40 +0900
committershimizukawa <shimizukawa@gmail.com>2015-12-19 19:00:39 +0900
commit0b0f6d66cb03faa8e9e442556d58e63a7e8cf8d6 (patch)
tree60dd6e3793281704224f3d73780f9e0f8c71bb1d /tests/path.py
parent157375baa31b6106b83ccf136d913ba7d54eb05d (diff)
downloadsphinx-git-0b0f6d66cb03faa8e9e442556d58e63a7e8cf8d6.tar.gz
Fix #2158: test_latex_build.test_footnote and some tests fail on Windows environment with py3
Diffstat (limited to 'tests/path.py')
-rwxr-xr-xtests/path.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/path.py b/tests/path.py
index 2f0cdc062..9e6baa36e 100755
--- a/tests/path.py
+++ b/tests/path.py
@@ -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: