summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_shutil.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2014-01-01 01:51:58 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2014-01-01 01:51:58 (GMT)
commitb6728880927dbd290fd11f553b42316eb9c4b09d (patch)
treeb3c05462c4ff48a1c353fcdaf1d0e1d257983a3d /Lib/test/test_shutil.py
parent089305f8f69737e66c2268fd4dce0d3660301c6e (diff)
parent3f48ac98c04fc17f12c63dcf593dd0c19379c7df (diff)
downloadcpython-b6728880927dbd290fd11f553b42316eb9c4b09d.zip
cpython-b6728880927dbd290fd11f553b42316eb9c4b09d.tar.gz
cpython-b6728880927dbd290fd11f553b42316eb9c4b09d.tar.bz2
Issue #20055: Fix test_shutil under Windows with symlink privileges held.
Patch by Vajrasky Kok.
Diffstat (limited to 'Lib/test/test_shutil.py')
-rw-r--r--Lib/test/test_shutil.py32
1 files changed, 19 insertions, 13 deletions
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index 98ea6d1..9bedaee 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -288,18 +288,20 @@ class TestShutil(unittest.TestCase):
self.assertNotEqual(os.stat(src).st_mode, os.stat(dst).st_mode)
shutil.copymode(src, dst)
self.assertEqual(os.stat(src).st_mode, os.stat(dst).st_mode)
- # follow src link
- os.chmod(dst, stat.S_IRWXO)
- shutil.copymode(src_link, dst)
- self.assertEqual(os.stat(src).st_mode, os.stat(dst).st_mode)
- # follow dst link
- os.chmod(dst, stat.S_IRWXO)
- shutil.copymode(src, dst_link)
- self.assertEqual(os.stat(src).st_mode, os.stat(dst).st_mode)
- # follow both links
- os.chmod(dst, stat.S_IRWXO)
- shutil.copymode(src_link, dst)
- self.assertEqual(os.stat(src).st_mode, os.stat(dst).st_mode)
+ # On Windows, os.chmod does not follow symlinks (issue #15411)
+ if os.name != 'nt':
+ # follow src link
+ os.chmod(dst, stat.S_IRWXO)
+ shutil.copymode(src_link, dst)
+ self.assertEqual(os.stat(src).st_mode, os.stat(dst).st_mode)
+ # follow dst link
+ os.chmod(dst, stat.S_IRWXO)
+ shutil.copymode(src, dst_link)
+ self.assertEqual(os.stat(src).st_mode, os.stat(dst).st_mode)
+ # follow both links
+ os.chmod(dst, stat.S_IRWXO)
+ shutil.copymode(src_link, dst_link)
+ self.assertEqual(os.stat(src).st_mode, os.stat(dst).st_mode)
@unittest.skipUnless(hasattr(os, 'lchmod'), 'requires os.lchmod')
@support.skip_unless_symlink
@@ -1554,7 +1556,11 @@ class TestMove(unittest.TestCase):
dst_link = os.path.join(self.dst_dir, 'quux')
shutil.move(dst, dst_link)
self.assertTrue(os.path.islink(dst_link))
- self.assertEqual(os.path.realpath(src), os.path.realpath(dst_link))
+ # On Windows, os.path.realpath does not follow symlinks (issue #9949)
+ if os.name == 'nt':
+ self.assertEqual(os.path.realpath(src), os.readlink(dst_link))
+ else:
+ self.assertEqual(os.path.realpath(src), os.path.realpath(dst_link))
@support.skip_unless_symlink
@mock_rename