GH-127381: pathlib ABCs: remove PathBase.lstat() (#127382)

Remove the `PathBase.lstat()` method, which is a trivial variation of
`stat()`.

No user-facing changes because the pathlib ABCs are still private.
This commit is contained in:
Barney Gale 2024-11-29 21:03:39 +00:00 committed by GitHub
parent 15d6506d17
commit 38264a060a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 26 additions and 29 deletions

View file

@ -1351,7 +1351,6 @@ class PathBaseTest(PurePathBaseTest):
p = self.cls('')
e = UnsupportedOperation
self.assertRaises(e, p.stat)
self.assertRaises(e, p.lstat)
self.assertRaises(e, p.exists)
self.assertRaises(e, p.samefile, 'foo')
self.assertRaises(e, p.is_dir)
@ -2671,17 +2670,6 @@ class DummyPathTest(DummyPurePathTest):
st = p.stat()
self.assertEqual(st, p.stat(follow_symlinks=False))
@needs_symlinks
def test_lstat(self):
p = self.cls(self.base)/ 'linkA'
st = p.stat()
self.assertNotEqual(st, p.lstat())
def test_lstat_nosymlink(self):
p = self.cls(self.base) / 'fileA'
st = p.stat()
self.assertEqual(st, p.lstat())
def test_is_dir(self):
P = self.cls(self.base)
self.assertTrue((P / 'dirA').is_dir())
@ -2868,11 +2856,13 @@ class DummyPathTest(DummyPurePathTest):
base = self.cls(self.base)
base.joinpath('dirA')._delete()
self.assertRaises(FileNotFoundError, base.joinpath('dirA').stat)
self.assertRaises(FileNotFoundError, base.joinpath('dirA', 'linkC').lstat)
self.assertRaises(FileNotFoundError, base.joinpath('dirA', 'linkC').stat,
follow_symlinks=False)
base.joinpath('dirB')._delete()
self.assertRaises(FileNotFoundError, base.joinpath('dirB').stat)
self.assertRaises(FileNotFoundError, base.joinpath('dirB', 'fileB').stat)
self.assertRaises(FileNotFoundError, base.joinpath('dirB', 'linkD').lstat)
self.assertRaises(FileNotFoundError, base.joinpath('dirB', 'linkD').stat,
follow_symlinks=False)
base.joinpath('dirC')._delete()
self.assertRaises(FileNotFoundError, base.joinpath('dirC').stat)
self.assertRaises(FileNotFoundError, base.joinpath('dirC', 'dirD').stat)