mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
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.
This commit is contained in:
parent
dbc1752d41
commit
c68a93c582
6 changed files with 96 additions and 4 deletions
|
@ -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')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue