summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_shutil.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-10-14 22:22:30 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-10-14 22:22:30 (GMT)
commit99d848bd4ba7bc0df689709f3854d67c6d82a757 (patch)
treed02592b257cb7411854f5f49e904b054af391a90 /Lib/test/test_shutil.py
parent80800d35713912eb4b9486033c1ce86bce263728 (diff)
downloadcpython-99d848bd4ba7bc0df689709f3854d67c6d82a757.zip
cpython-99d848bd4ba7bc0df689709f3854d67c6d82a757.tar.gz
cpython-99d848bd4ba7bc0df689709f3854d67c6d82a757.tar.bz2
Merged revisions 85503 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r85503 | antoine.pitrou | 2010-10-15 00:11:44 +0200 (ven., 15 oct. 2010) | 2 lines More proper closing of files ........
Diffstat (limited to 'Lib/test/test_shutil.py')
-rw-r--r--Lib/test/test_shutil.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index d683935..648a2cd 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -277,7 +277,8 @@ class TestShutil(unittest.TestCase):
os.link(src, dst)
self.assertRaises(shutil.Error, shutil.copyfile, src, dst)
- self.assertEqual(open(src,'r').read(), 'cheddar')
+ with open(src, 'r') as f:
+ self.assertEqual(f.read(), 'cheddar')
os.remove(dst)
# Using `src` here would mean we end up with a symlink pointing
@@ -285,7 +286,8 @@ class TestShutil(unittest.TestCase):
# TESTFN/cheese.
os.symlink('cheese', dst)
self.assertRaises(shutil.Error, shutil.copyfile, src, dst)
- self.assertEqual(open(src,'r').read(), 'cheddar')
+ with open(src, 'r') as f:
+ self.assertEqual(f.read(), 'cheddar')
os.remove(dst)
finally:
try:
@@ -588,9 +590,11 @@ class TestMove(unittest.TestCase):
pass
def _check_move_file(self, src, dst, real_dst):
- contents = open(src, "rb").read()
+ with open(src, "rb") as f:
+ contents = f.read()
shutil.move(src, dst)
- self.assertEqual(contents, open(real_dst, "rb").read())
+ with open(real_dst, "rb") as f:
+ self.assertEqual(contents, f.read())
self.assertFalse(os.path.exists(src))
def _check_move_dir(self, src, dst, real_dst):