diff options
author | Barney Gale <barney.gale@gmail.com> | 2024-08-11 21:43:18 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-11 21:43:18 (GMT) |
commit | a6644d446416dbe3eab26839a32f79c4e73d3aeb (patch) | |
tree | a356f0865fe48c81c2bba66b69dd2029b1ddc424 /Lib/test/test_pathlib/test_pathlib.py | |
parent | ea70439bd2b5a1c881342646f30942f527f61373 (diff) | |
download | cpython-a6644d446416dbe3eab26839a32f79c4e73d3aeb.zip cpython-a6644d446416dbe3eab26839a32f79c4e73d3aeb.tar.gz cpython-a6644d446416dbe3eab26839a32f79c4e73d3aeb.tar.bz2 |
GH-73991: Rework `pathlib.Path.copytree()` into `copy()` (#122369)
Rename `pathlib.Path.copy()` to `_copy_file()` (i.e. make it private.)
Rename `pathlib.Path.copytree()` to `copy()`, and add support for copying
non-directories. This simplifies the interface for users, and nicely
complements the upcoming `move()` and `delete()` methods (which will also
accept any type of file.)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_pathlib/test_pathlib.py')
-rw-r--r-- | Lib/test/test_pathlib/test_pathlib.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Lib/test/test_pathlib/test_pathlib.py b/Lib/test/test_pathlib/test_pathlib.py index 9e92225..fa151b5 100644 --- a/Lib/test/test_pathlib/test_pathlib.py +++ b/Lib/test/test_pathlib/test_pathlib.py @@ -709,19 +709,19 @@ class PathTest(test_pathlib_abc.DummyPathTest, PurePathTest): @unittest.skipIf(sys.platform == "win32" or sys.platform == "wasi", "directories are always readable on Windows and WASI") @unittest.skipIf(root_in_posix, "test fails with root privilege") - def test_copytree_no_read_permission(self): + def test_copy_dir_no_read_permission(self): base = self.cls(self.base) source = base / 'dirE' target = base / 'copyE' - self.assertRaises(PermissionError, source.copytree, target) + self.assertRaises(PermissionError, source.copy, target) self.assertFalse(target.exists()) errors = [] - source.copytree(target, on_error=errors.append) + source.copy(target, on_error=errors.append) self.assertEqual(len(errors), 1) self.assertIsInstance(errors[0], PermissionError) self.assertFalse(target.exists()) - def test_copytree_preserve_metadata(self): + def test_copy_dir_preserve_metadata(self): base = self.cls(self.base) source = base / 'dirC' if hasattr(os, 'chmod'): @@ -729,7 +729,7 @@ class PathTest(test_pathlib_abc.DummyPathTest, PurePathTest): if hasattr(os, 'chflags') and hasattr(stat, 'UF_NODUMP'): os.chflags(source / 'fileC', stat.UF_NODUMP) target = base / 'copyA' - source.copytree(target, preserve_metadata=True) + source.copy(target, preserve_metadata=True) for subpath in ['.', 'fileC', 'dirD', 'dirD/fileD']: source_st = source.joinpath(subpath).stat() @@ -741,13 +741,13 @@ class PathTest(test_pathlib_abc.DummyPathTest, PurePathTest): self.assertEqual(source_st.st_flags, target_st.st_flags) @os_helper.skip_unless_xattr - def test_copytree_preserve_metadata_xattrs(self): + def test_copy_dir_preserve_metadata_xattrs(self): base = self.cls(self.base) source = base / 'dirC' source_file = source.joinpath('dirD', 'fileD') os.setxattr(source_file, b'user.foo', b'42') target = base / 'copyA' - source.copytree(target, preserve_metadata=True) + source.copy(target, preserve_metadata=True) target_file = target.joinpath('dirD', 'fileD') self.assertEqual(os.getxattr(target_file, b'user.foo'), b'42') |