summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-01-29 20:26:59 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-01-29 20:26:59 (GMT)
commit0dcc3cdca5b6f0fcb64cce756e552f43c74785e7 (patch)
tree278dfe2d4a0ba830b759a2b039e46b74d598bb1e /Lib/test
parent891f2631f576dfc515627074cccb07e0ffdff156 (diff)
downloadcpython-0dcc3cdca5b6f0fcb64cce756e552f43c74785e7.zip
cpython-0dcc3cdca5b6f0fcb64cce756e552f43c74785e7.tar.gz
cpython-0dcc3cdca5b6f0fcb64cce756e552f43c74785e7.tar.bz2
Merged revisions 69100 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r69100 | antoine.pitrou | 2009-01-29 21:19:34 +0100 (jeu., 29 janv. 2009) | 5 lines Issue #2047: shutil.move() could believe that its destination path was inside its source path if it began with the same letters (e.g. "src" vs. "src.new"). ........
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_shutil.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index ad60a44..c7dd1b3 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -340,7 +340,29 @@ class TestMove(unittest.TestCase):
dst = os.path.join(self.src_dir, "bar")
self.assertRaises(shutil.Error, shutil.move, self.src_dir, dst)
+ def test_destinsrc_false_negative(self):
+ os.mkdir(TESTFN)
+ try:
+ for src, dst in [('srcdir', 'srcdir/dest')]:
+ src = os.path.join(TESTFN, src)
+ dst = os.path.join(TESTFN, dst)
+ self.assert_(shutil.destinsrc(src, dst),
+ msg='destinsrc() wrongly concluded that '
+ 'dst (%s) is not in src (%s)' % (dst, src))
+ finally:
+ shutil.rmtree(TESTFN, ignore_errors=True)
+ def test_destinsrc_false_positive(self):
+ os.mkdir(TESTFN)
+ try:
+ for src, dst in [('srcdir', 'src/dest'), ('srcdir', 'srcdir.new')]:
+ src = os.path.join(TESTFN, src)
+ dst = os.path.join(TESTFN, dst)
+ self.failIf(shutil.destinsrc(src, dst),
+ msg='destinsrc() wrongly concluded that '
+ 'dst (%s) is in src (%s)' % (dst, src))
+ finally:
+ shutil.rmtree(TESTFN, ignore_errors=True)
def test_main():
support.run_unittest(TestShutil, TestMove)