Unwrap too-smart loop: we can't use `src` for both hard and symbolic links.

This commit is contained in:
Johannes Gijsbers 2004-08-14 13:57:08 +00:00
parent 46f1459860
commit 68128715f2
1 changed files with 16 additions and 8 deletions

View File

@ -37,8 +37,16 @@ class TestShutil(unittest.TestCase):
f = open(src, 'w')
f.write('cheddar')
f.close()
for funcname in 'link','symlink':
getattr(os, funcname)(src, 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)