Issue #12451: Add support.create_empty_file()

We don't need to create a temporary buffered binary or text file object just to
create an empty file.

Replace also os.fdopen(handle).close() by os.close(handle).
This commit is contained in:
Victor Stinner 2011-06-30 23:25:47 +02:00
parent 61600cb0c3
commit bf816223df
17 changed files with 50 additions and 53 deletions

View file

@ -10,7 +10,7 @@ from distutils.core import Distribution
from distutils.errors import DistutilsFileError
from distutils.tests import support
from test.support import run_unittest
from test.support import run_unittest, create_empty_file
class BuildPyTestCase(support.TempdirManager,
@ -71,11 +71,11 @@ class BuildPyTestCase(support.TempdirManager,
# create the distribution files.
sources = self.mkdtemp()
open(os.path.join(sources, "__init__.py"), "w").close()
create_empty_file(os.path.join(sources, "__init__.py"))
testdir = os.path.join(sources, "doc")
os.mkdir(testdir)
open(os.path.join(testdir, "testfile"), "w").close()
create_empty_file(os.path.join(testdir, "testfile"))
os.chdir(sources)
old_stdout = sys.stdout