Commit 7ccfc71b authored by Antoine Pitrou's avatar Antoine Pitrou

Issue #20055: Fix test_shutil under Windows with symlink privileges held.

Patch by Vajrasky Kok.
parents 731b9693 346c6019
......@@ -288,6 +288,8 @@ 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)
# 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)
......@@ -298,7 +300,7 @@ class TestShutil(unittest.TestCase):
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)
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')
......@@ -1554,6 +1556,10 @@ 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))
# 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
......
......@@ -267,6 +267,9 @@ IDLE
Tests
-----
- Issue #20055: Fix test_shutil under Windows with symlink privileges held.
Patch by Vajrasky Kok.
- Issue #20070: Don't run test_urllib2net when network resources are not
enabled.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment