mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
GH-127381: pathlib ABCs: remove PathBase.unlink()
and rmdir()
(#127736)
Virtual filesystems don't always make a distinction between deleting files and empty directories, and sometimes support deleting non-empty directories in a single operation. Here we remove `PathBase.unlink()` and `rmdir()`, leaving `_delete()` as the sole deletion method, now made abstract. I hope to drop the underscore prefix later on.
This commit is contained in:
parent
2367759212
commit
7f8ec52302
4 changed files with 48 additions and 86 deletions
|
@ -1352,6 +1352,25 @@ class PathTest(test_pathlib_abc.DummyPathTest, PurePathTest):
|
|||
self.assertEqual(expected_gid, gid_2)
|
||||
self.assertEqual(expected_name, link.group(follow_symlinks=False))
|
||||
|
||||
def test_unlink(self):
|
||||
p = self.cls(self.base) / 'fileA'
|
||||
p.unlink()
|
||||
self.assertFileNotFound(p.stat)
|
||||
self.assertFileNotFound(p.unlink)
|
||||
|
||||
def test_unlink_missing_ok(self):
|
||||
p = self.cls(self.base) / 'fileAAA'
|
||||
self.assertFileNotFound(p.unlink)
|
||||
p.unlink(missing_ok=True)
|
||||
|
||||
def test_rmdir(self):
|
||||
p = self.cls(self.base) / 'dirA'
|
||||
for q in p.iterdir():
|
||||
q.unlink()
|
||||
p.rmdir()
|
||||
self.assertFileNotFound(p.stat)
|
||||
self.assertFileNotFound(p.unlink)
|
||||
|
||||
@needs_symlinks
|
||||
def test_delete_symlink(self):
|
||||
tmp = self.cls(self.base, 'delete')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue