summaryrefslogtreecommitdiff
path: root/Lib/test/test_unicode_file.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_unicode_file.py')
-rw-r--r--Lib/test/test_unicode_file.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/Lib/test/test_unicode_file.py b/Lib/test/test_unicode_file.py
index 6c2011ace8..faa8da3c0a 100644
--- a/Lib/test/test_unicode_file.py
+++ b/Lib/test/test_unicode_file.py
@@ -6,7 +6,7 @@ import unicodedata
import unittest
from test.support import (run_unittest, rmtree,
- TESTFN_ENCODING, TESTFN_UNICODE, TESTFN_UNENCODABLE)
+ TESTFN_ENCODING, TESTFN_UNICODE, TESTFN_UNENCODABLE, create_empty_file)
if not os.path.supports_unicode_filenames:
try:
@@ -56,16 +56,20 @@ class TestUnicodeFiles(unittest.TestCase):
# Should be able to rename the file using either name.
self.assertTrue(os.path.isfile(filename1)) # must exist.
os.rename(filename1, filename2 + ".new")
- self.assertTrue(os.path.isfile(filename1+".new"))
+ self.assertFalse(os.path.isfile(filename2))
+ self.assertTrue(os.path.isfile(filename1 + '.new'))
os.rename(filename1 + ".new", filename2)
+ self.assertFalse(os.path.isfile(filename1 + '.new'))
self.assertTrue(os.path.isfile(filename2))
shutil.copy(filename1, filename2 + ".new")
os.unlink(filename1 + ".new") # remove using equiv name.
# And a couple of moves, one using each name.
shutil.move(filename1, filename2 + ".new")
- self.assertTrue(not os.path.exists(filename2))
+ self.assertFalse(os.path.exists(filename2))
+ self.assertTrue(os.path.exists(filename1 + '.new'))
shutil.move(filename1 + ".new", filename2)
+ self.assertFalse(os.path.exists(filename2 + '.new'))
self.assertTrue(os.path.exists(filename1))
# Note - due to the implementation of shutil.move,
# it tries a rename first. This only fails on Windows when on
@@ -73,10 +77,12 @@ class TestUnicodeFiles(unittest.TestCase):
# So we test the shutil.copy2 function, which is the thing most
# likely to fail.
shutil.copy2(filename1, filename2 + ".new")
+ self.assertTrue(os.path.isfile(filename1 + '.new'))
os.unlink(filename1 + ".new")
+ self.assertFalse(os.path.exists(filename2 + '.new'))
def _do_directory(self, make_name, chdir_name):
- cwd = os.getcwdb()
+ cwd = os.getcwd()
if os.path.isdir(make_name):
rmtree(make_name)
os.mkdir(make_name)
@@ -99,8 +105,7 @@ class TestUnicodeFiles(unittest.TestCase):
# top-level 'test' functions would be if they could take params
def _test_single(self, filename):
remove_if_exists(filename)
- f = open(filename, "w")
- f.close()
+ create_empty_file(filename)
try:
self._do_single(filename)
finally: