[Python-checkins] python/dist/src/Lib/test test_shutil.py,1.4,1.5
jlgijsbers at users.sourceforge.net
jlgijsbers at users.sourceforge.net
Sat Aug 14 15:30:04 CEST 2004
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13343/test
Modified Files:
test_shutil.py
Log Message:
Raise an exception when src and dst refer to the same file via a hard link or a
symbolic link (bug #851123 / patch #854853, thanks Gregory Ball).
Index: test_shutil.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_shutil.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** test_shutil.py 14 Jul 2004 00:48:32 -0000 1.4
--- test_shutil.py 14 Aug 2004 13:30:02 -0000 1.5
***************
*** 7,10 ****
--- 7,11 ----
import os.path
from test import test_support
+ from test.test_support import TESTFN
class TestShutil(unittest.TestCase):
***************
*** 27,30 ****
--- 28,51 ----
pass
+ if hasattr(os, "symlink"):
+ 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()
+ 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)
+ finally:
+ try:
+ shutil.rmtree(TESTFN)
+ except OSError:
+ pass
More information about the Python-checkins
mailing list