diff options
author | Larry Hastings <larry@hastings.org> | 2012-06-22 16:30:09 -0700 |
---|---|---|
committer | Larry Hastings <larry@hastings.org> | 2012-06-22 16:30:09 -0700 |
commit | 9cf065cfdc4245ea7e31edcb2e6ede0cea47d148 (patch) | |
tree | 22d8450865a023586034d555ae72e3753f95e84c /Lib/test/test_shutil.py | |
parent | f0f4742b495554238d1204ce0002c1ef1ba23507 (diff) | |
download | cpython-git-9cf065cfdc4245ea7e31edcb2e6ede0cea47d148.tar.gz |
Issue #14626: Large refactoring of functions / parameters in the os module.
Many functions now support "dir_fd" and "follow_symlinks" parameters;
some also support accepting an open file descriptor in place of of a path
string. Added os.support_* collections as LBYL helpers. Removed many
functions only previously seen in 3.3 alpha releases (often starting with
"f" or "l", or ending with "at"). Originally suggested by Serhiy Storchaka;
implemented by Larry Hastings.
Diffstat (limited to 'Lib/test/test_shutil.py')
-rw-r--r-- | Lib/test/test_shutil.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py index 559f05b32b..ad835aee2b 100644 --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -268,7 +268,7 @@ class TestShutil(unittest.TestCase): # don't follow shutil.copystat(src_link, dst_link, symlinks=True) dst_link_stat = os.lstat(dst_link) - if hasattr(os, 'lutimes'): + if os.utime in os.supports_follow_symlinks: for attr in 'st_atime', 'st_mtime': # The modification times may be truncated in the new file. self.assertLessEqual(getattr(src_link_stat, attr), @@ -334,11 +334,11 @@ class TestShutil(unittest.TestCase): write_file(dst, 'bar') os_error = OSError(errno.EPERM, 'EPERM') - def _raise_on_user_foo(fname, attr, val): + def _raise_on_user_foo(fname, attr, val, **kwargs): if attr == 'user.foo': raise os_error else: - orig_setxattr(fname, attr, val) + orig_setxattr(fname, attr, val, **kwargs) try: orig_setxattr = os.setxattr os.setxattr = _raise_on_user_foo @@ -361,13 +361,13 @@ class TestShutil(unittest.TestCase): write_file(src, 'foo') os.symlink(src, src_link) os.setxattr(src, 'trusted.foo', b'42') - os.lsetxattr(src_link, 'trusted.foo', b'43') + os.setxattr(src_link, 'trusted.foo', b'43', follow_symlinks=False) dst = os.path.join(tmp_dir, 'bar') 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) - self.assertEqual(os.lgetxattr(dst_link, 'trusted.foo'), b'43') + 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) self.assertEqual(os.getxattr(dst, 'trusted.foo'), b'43') @@ -419,7 +419,7 @@ class TestShutil(unittest.TestCase): self.assertTrue(os.path.islink(dst)) self.assertEqual(os.readlink(dst), os.readlink(src_link)) dst_stat = os.lstat(dst) - if hasattr(os, 'lutimes'): + if os.utime in os.supports_follow_symlinks: for attr in 'st_atime', 'st_mtime': # The modification times may be truncated in the new file. self.assertLessEqual(getattr(src_link_stat, attr), |