mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
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:
parent
61600cb0c3
commit
bf816223df
17 changed files with 50 additions and 53 deletions
|
@ -7,7 +7,7 @@ import tempfile
|
|||
import unittest
|
||||
|
||||
from imp import cache_from_source
|
||||
from test.support import run_unittest
|
||||
from test.support import run_unittest, create_empty_file
|
||||
|
||||
class TestImport(unittest.TestCase):
|
||||
|
||||
|
@ -29,7 +29,7 @@ class TestImport(unittest.TestCase):
|
|||
self.package_dir = os.path.join(self.test_dir,
|
||||
self.package_name)
|
||||
os.mkdir(self.package_dir)
|
||||
open(os.path.join(self.package_dir, '__init__.py'), 'w').close()
|
||||
create_empty_file(os.path.join(self.package_dir, '__init__.py'))
|
||||
self.module_path = os.path.join(self.package_dir, 'foo.py')
|
||||
|
||||
def tearDown(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue