summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Gijsbers <jlg@dds.nl>2004-08-14 13:57:08 (GMT)
committerJohannes Gijsbers <jlg@dds.nl>2004-08-14 13:57:08 (GMT)
commit68128715f2b7d4c73f55d576d500b6cd3d41b378 (patch)
tree18f00d23e5c4e92ea7262288461ab7aba3ec7f56
parent46f1459860280d9f57d92f1fb389f657e0b2724b (diff)
downloadcpython-68128715f2b7d4c73f55d576d500b6cd3d41b378.zip
cpython-68128715f2b7d4c73f55d576d500b6cd3d41b378.tar.gz
cpython-68128715f2b7d4c73f55d576d500b6cd3d41b378.tar.bz2
Unwrap too-smart loop: we can't use `src` for both hard and symbolic links.
-rw-r--r--Lib/test/test_shutil.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index 083dbda..9e5f6ff 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -31,17 +31,25 @@ class TestShutil(unittest.TestCase):
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')
+ src = os.path.join(TESTFN, 'cheese')
+ dst = os.path.join(TESTFN, 'shop')
try:
- f = open(src,'w')
+ f = open(src, 'w')
f.write('cheddar')
f.close()
- for funcname in 'link','symlink':
- getattr(os, funcname)(src, dst)
- self.assertRaises(shutil.Error, shutil.copyfile, src, dst)
- self.assertEqual(open(src,'r').read(), 'cheddar')
- os.remove(dst)
+
+ os.link(src, dst)
+ self.assertRaises(shutil.Error, shutil.copyfile, src, dst)
+ self.assertEqual(open(src,'r').read(), 'cheddar')
+ os.remove(dst)
+
+ # Using `src` here would mean we end up with a symlink pointing
+ # to TESTFN/TESTFN/cheese, while it should point at
+ # TESTFN/cheese.
+ os.symlink('cheese', dst)
+ self.assertRaises(shutil.Error, shutil.copyfile, src, dst)
+ self.assertEqual(open(src,'r').read(), 'cheddar')
+ os.remove(dst)
finally:
try:
shutil.rmtree(TESTFN)