diff options
author | Barney Gale <barney.gale@gmail.com> | 2024-08-26 13:14:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-26 13:14:23 (GMT) |
commit | c68a93c582cc733c399a1cf9e850e5071f79aec1 (patch) | |
tree | 7cf68402c646cd8c5341af70eaf4f5ce9672cbdc /Lib/test/test_pathlib/test_pathlib.py | |
parent | dbc1752d4107532d312c78263212e807a3674eb1 (diff) | |
download | cpython-c68a93c582cc733c399a1cf9e850e5071f79aec1.zip cpython-c68a93c582cc733c399a1cf9e850e5071f79aec1.tar.gz cpython-c68a93c582cc733c399a1cf9e850e5071f79aec1.tar.bz2 |
GH-73991: Add `pathlib.Path.copy_into()` and `move_into()` (#123314)
These two methods accept an *existing* directory path, onto which we join
the source path's base name to form the final target path.
A possible alternative implementation is to check for directories in
`copy()` and `move()` and adjust the target path, which is done in several
`shutil` functions. This behaviour is helpful in a shell context, but
less so in a stored program that explicitly specifies destinations. For
example, a user that calls `Path('foo.py').copy('bar.py')` might not
imagine that `bar.py/foo.py` would be created, but under the alternative
implementation this will happen if `bar.py` is an existing directory.
Diffstat (limited to 'Lib/test/test_pathlib/test_pathlib.py')
-rw-r--r-- | Lib/test/test_pathlib/test_pathlib.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_pathlib/test_pathlib.py b/Lib/test/test_pathlib/test_pathlib.py index 4d38246..080b8df 100644 --- a/Lib/test/test_pathlib/test_pathlib.py +++ b/Lib/test/test_pathlib/test_pathlib.py @@ -861,6 +861,14 @@ class PathTest(test_pathlib_abc.DummyPathTest, PurePathTest): def test_move_dangling_symlink_other_fs(self): self.test_move_dangling_symlink() + @patch_replace + def test_move_into_other_os(self): + self.test_move_into() + + @patch_replace + def test_move_into_empty_name_other_os(self): + self.test_move_into_empty_name() + def test_resolve_nonexist_relative_issue38671(self): p = self.cls('non', 'exist') |