remove tests.util.write_file duplicated implementation.

This commit is contained in:
Takayuki Shimizukawa
2014-04-28 19:58:26 +09:00
parent 638458038d
commit 1e4b390b22
3 changed files with 11 additions and 23 deletions
+1 -14
View File
@@ -12,7 +12,6 @@ import StringIO
import tempfile
import shutil
import re
from codecs import open
from functools import wraps
from sphinx import application
@@ -28,7 +27,7 @@ __all__ = [
'test_root', 'test_roots', 'raises', 'raises_msg',
'skip_if', 'skip_unless', 'skip_unless_importable', 'Struct',
'ListOutput', 'TestApp', 'with_app', 'gen_with_app',
'path', 'with_tempdir', 'write_file',
'path', 'with_tempdir',
'sprint', 'remove_unicode_literals',
]
@@ -224,18 +223,6 @@ def with_tempdir(func):
return new_func
def write_file(name, contents, encoding=None):
if encoding is None:
mode = 'wb'
if isinstance(contents, unicode):
contents = contents.encode('ascii')
else:
mode = 'w'
f = open(str(name), mode, encoding=encoding)
f.write(contents)
f.close()
def sprint(*args):
sys.stderr.write(' '.join(map(str, args)) + '\n')