summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorLarry Hastings <larry@hastings.org>2012-07-15 17:57:38 (GMT)
committerLarry Hastings <larry@hastings.org>2012-07-15 17:57:38 (GMT)
commitb40380667c98a3ab7e244e036944f731d61ffc27 (patch)
treebfb57dbbb5fea7e9398adf44366953c86f8462f4 /Lib/test
parent509d87d4a06f2812c82df9b2fab83272f6463a81 (diff)
downloadcpython-b40380667c98a3ab7e244e036944f731d61ffc27.zip
cpython-b40380667c98a3ab7e244e036944f731d61ffc27.tar.gz
cpython-b40380667c98a3ab7e244e036944f731d61ffc27.tar.bz2
Issue #15202: Consistently use the name "follow_symlinks" for
new parameters in os and shutil functions. Patch by Serhiy Storchaka.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_os.py15
-rw-r--r--Lib/test/test_shutil.py28
2 files changed, 22 insertions, 21 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 7c73f1e..5c0b0c8 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -758,10 +758,11 @@ class FwalkTests(WalkTests):
"""
compare with walk() results.
"""
- for topdown, followlinks in itertools.product((True, False), repeat=2):
- d = {'topdown': topdown, 'followlinks': followlinks}
- walk_kwargs.update(d)
- fwalk_kwargs.update(d)
+ walk_kwargs = walk_kwargs.copy()
+ fwalk_kwargs = fwalk_kwargs.copy()
+ for topdown, follow_symlinks in itertools.product((True, False), repeat=2):
+ walk_kwargs.update(topdown=topdown, followlinks=follow_symlinks)
+ fwalk_kwargs.update(topdown=topdown, follow_symlinks=follow_symlinks)
expected = {}
for root, dirs, files in os.walk(**walk_kwargs):
@@ -787,9 +788,9 @@ class FwalkTests(WalkTests):
def test_yields_correct_dir_fd(self):
# check returned file descriptors
- for topdown, followlinks in itertools.product((True, False), repeat=2):
- args = support.TESTFN, topdown, None, followlinks
- for root, dirs, files, rootfd in os.fwalk(*args):
+ for topdown, follow_symlinks in itertools.product((True, False), repeat=2):
+ args = support.TESTFN, topdown, None
+ for root, dirs, files, rootfd in os.fwalk(*args, follow_symlinks=follow_symlinks):
# check that the FD is valid
os.fstat(rootfd)
# redundant check
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index cbbc36f..e5c38eb 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -277,17 +277,17 @@ class TestShutil(unittest.TestCase):
os.lchmod(src_link, stat.S_IRWXO|stat.S_IRWXG)
# link to link
os.lchmod(dst_link, stat.S_IRWXO)
- shutil.copymode(src_link, dst_link, symlinks=True)
+ shutil.copymode(src_link, dst_link, follow_symlinks=False)
self.assertEqual(os.lstat(src_link).st_mode,
os.lstat(dst_link).st_mode)
self.assertNotEqual(os.stat(src).st_mode, os.stat(dst).st_mode)
# src link - use chmod
os.lchmod(dst_link, stat.S_IRWXO)
- shutil.copymode(src_link, dst, symlinks=True)
+ shutil.copymode(src_link, dst, follow_symlinks=False)
self.assertEqual(os.stat(src).st_mode, os.stat(dst).st_mode)
# dst link - use chmod
os.lchmod(dst_link, stat.S_IRWXO)
- shutil.copymode(src, dst_link, symlinks=True)
+ shutil.copymode(src, dst_link, follow_symlinks=False)
self.assertEqual(os.stat(src).st_mode, os.stat(dst).st_mode)
@unittest.skipIf(hasattr(os, 'lchmod'), 'requires os.lchmod to be missing')
@@ -302,7 +302,7 @@ class TestShutil(unittest.TestCase):
write_file(dst, 'foo')
os.symlink(src, src_link)
os.symlink(dst, dst_link)
- shutil.copymode(src_link, dst_link, symlinks=True) # silent fail
+ shutil.copymode(src_link, dst_link, follow_symlinks=False) # silent fail
@support.skip_unless_symlink
def test_copystat_symlinks(self):
@@ -326,10 +326,10 @@ class TestShutil(unittest.TestCase):
src_link_stat = os.lstat(src_link)
# follow
if hasattr(os, 'lchmod'):
- shutil.copystat(src_link, dst_link, symlinks=False)
+ shutil.copystat(src_link, dst_link, follow_symlinks=True)
self.assertNotEqual(src_link_stat.st_mode, os.stat(dst).st_mode)
# don't follow
- shutil.copystat(src_link, dst_link, symlinks=True)
+ shutil.copystat(src_link, dst_link, follow_symlinks=False)
dst_link_stat = os.lstat(dst_link)
if os.utime in os.supports_follow_symlinks:
for attr in 'st_atime', 'st_mtime':
@@ -341,7 +341,7 @@ class TestShutil(unittest.TestCase):
if hasattr(os, 'lchflags') and hasattr(src_link_stat, 'st_flags'):
self.assertEqual(src_link_stat.st_flags, dst_link_stat.st_flags)
# tell to follow but dst is not a link
- shutil.copystat(src_link, dst, symlinks=True)
+ shutil.copystat(src_link, dst, follow_symlinks=False)
self.assertTrue(abs(os.stat(src).st_mtime - os.stat(dst).st_mtime) <
00000.1)
@@ -439,10 +439,10 @@ class TestShutil(unittest.TestCase):
dst_link = os.path.join(tmp_dir, 'qux')
write_file(dst, 'bar')
os.symlink(dst, dst_link)
- shutil._copyxattr(src_link, dst_link, symlinks=True)
+ shutil._copyxattr(src_link, dst_link, follow_symlinks=False)
self.assertEqual(os.getxattr(dst_link, 'trusted.foo', follow_symlinks=False), b'43')
self.assertRaises(OSError, os.getxattr, dst, 'trusted.foo')
- shutil._copyxattr(src_link, dst, symlinks=True)
+ shutil._copyxattr(src_link, dst, follow_symlinks=False)
self.assertEqual(os.getxattr(dst, 'trusted.foo'), b'43')
@support.skip_unless_symlink
@@ -456,12 +456,12 @@ class TestShutil(unittest.TestCase):
if hasattr(os, 'lchmod'):
os.lchmod(src_link, stat.S_IRWXU | stat.S_IRWXO)
# don't follow
- shutil.copy(src_link, dst, symlinks=False)
+ shutil.copy(src_link, dst, follow_symlinks=True)
self.assertFalse(os.path.islink(dst))
self.assertEqual(read_file(src), read_file(dst))
os.remove(dst)
# follow
- shutil.copy(src_link, dst, symlinks=True)
+ shutil.copy(src_link, dst, follow_symlinks=False)
self.assertTrue(os.path.islink(dst))
self.assertEqual(os.readlink(dst), os.readlink(src_link))
if hasattr(os, 'lchmod'):
@@ -483,12 +483,12 @@ class TestShutil(unittest.TestCase):
src_stat = os.stat(src)
src_link_stat = os.lstat(src_link)
# follow
- shutil.copy2(src_link, dst, symlinks=False)
+ shutil.copy2(src_link, dst, follow_symlinks=True)
self.assertFalse(os.path.islink(dst))
self.assertEqual(read_file(src), read_file(dst))
os.remove(dst)
# don't follow
- shutil.copy2(src_link, dst, symlinks=True)
+ shutil.copy2(src_link, dst, follow_symlinks=False)
self.assertTrue(os.path.islink(dst))
self.assertEqual(os.readlink(dst), os.readlink(src_link))
dst_stat = os.lstat(dst)
@@ -526,7 +526,7 @@ class TestShutil(unittest.TestCase):
write_file(src, 'foo')
os.symlink(src, link)
# don't follow
- shutil.copyfile(link, dst_link, symlinks=True)
+ shutil.copyfile(link, dst_link, follow_symlinks=False)
self.assertTrue(os.path.islink(dst_link))
self.assertEqual(os.readlink(link), os.readlink(dst_link))
# follow