[Python-checkins] cpython (3.3): Issue #20055: Fix test_shutil under Windows with symlink privileges held.

antoine.pitrou python-checkins at python.org
Wed Jan 1 02:52:09 CET 2014


http://hg.python.org/cpython/rev/0f888589dbcd
changeset:   88239:0f888589dbcd
branch:      3.3
parent:      88237:9c88280245e0
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Wed Jan 01 02:50:45 2014 +0100
summary:
  Issue #20055: Fix test_shutil under Windows with symlink privileges held.
Patch by Vajrasky Kok.

files:
  Lib/test/test_shutil.py |  32 +++++++++++++++++-----------
  Misc/NEWS               |   3 ++
  2 files changed, 22 insertions(+), 13 deletions(-)


diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -287,18 +287,20 @@
         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
@@ -1543,7 +1545,11 @@
         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
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -197,6 +197,9 @@
 Tests
 -----
 
+- Issue #20055: Fix test_shutil under Windows with symlink privileges held.
+  Patch by Vajrasky Kok.
+
 - Issue #19938: Re-enabled test_bug_1333982 in test_dis, which had been
   disabled since 3.0 due to the changes in listcomp handling.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list