[Python-checkins] r86817 - python/branches/py3k-stat-on-windows/Lib/test/test_shutil.py
hirokazu.yamamoto
python-checkins at python.org
Fri Nov 26 19:44:28 CET 2010
Author: hirokazu.yamamoto
Date: Fri Nov 26 19:44:28 2010
New Revision: 86817
Log:
Now can reproduce the error on AMD64 Windows Server 2008
even where os.symlink is not supported.
Modified:
python/branches/py3k-stat-on-windows/Lib/test/test_shutil.py
Modified: python/branches/py3k-stat-on-windows/Lib/test/test_shutil.py
==============================================================================
--- python/branches/py3k-stat-on-windows/Lib/test/test_shutil.py (original)
+++ python/branches/py3k-stat-on-windows/Lib/test/test_shutil.py Fri Nov 26 19:44:28 2010
@@ -271,24 +271,32 @@
shutil.rmtree(src_dir)
shutil.rmtree(os.path.dirname(dst_dir))
- @support.skip_unless_symlink
+ @unittest.skipUnless(hasattr(os, 'link'), 'requires os.link')
def test_dont_copy_file_onto_link_to_itself(self):
# bug 851123.
os.mkdir(TESTFN)
src = os.path.join(TESTFN, 'cheese')
dst = os.path.join(TESTFN, 'shop')
try:
- f = open(src, 'w')
- f.write('cheddar')
- f.close()
-
- if hasattr(os, "link"):
- os.link(src, dst)
- self.assertRaises(shutil.Error, shutil.copyfile, src, dst)
- with open(src, 'r') as f:
- self.assertEqual(f.read(), 'cheddar')
- os.remove(dst)
+ with open(src, 'w') as f:
+ f.write('cheddar')
+ os.link(src, dst)
+ self.assertRaises(shutil.Error, shutil.copyfile, src, dst)
+ with open(src, 'r') as f:
+ self.assertEqual(f.read(), 'cheddar')
+ os.remove(dst)
+ finally:
+ shutil.rmtree(TESTFN, ignore_errors=True)
+ @support.skip_unless_symlink
+ def test_dont_copy_file_onto_symlink_to_itself(self):
+ # bug 851123.
+ os.mkdir(TESTFN)
+ src = os.path.join(TESTFN, 'cheese')
+ dst = os.path.join(TESTFN, 'shop')
+ try:
+ with open(src, 'w') as f:
+ f.write('cheddar')
# Using `src` here would mean we end up with a symlink pointing
# to TESTFN/TESTFN/cheese, while it should point at
# TESTFN/cheese.
@@ -298,10 +306,7 @@
self.assertEqual(f.read(), 'cheddar')
os.remove(dst)
finally:
- try:
- shutil.rmtree(TESTFN)
- except OSError:
- pass
+ shutil.rmtree(TESTFN, ignore_errors=True)
@support.skip_unless_symlink
def test_rmtree_on_symlink(self):
More information about the Python-checkins
mailing list