GH-130614: pathlib ABCs: revise test suite for readable paths (#131018)

Test `pathlib.types._ReadablePath` in a dedicated test module. These tests
cover `ReadableZipPath`, `ReadableLocalPath` and `Path`, where the former
two classes are implementations of `_ReadablePath` for use in tests.
This commit is contained in:
Barney Gale 2025-03-11 20:54:22 +00:00 committed by GitHub
parent 24070492cf
commit ad90c5fabc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 759 additions and 268 deletions

View file

@ -2429,6 +2429,33 @@ class PathTest(test_pathlib_abc.RWPathTest, PurePathTest):
with self.assertRaises(pathlib.UnsupportedOperation):
q.symlink_to(p)
def test_info_exists_caching(self):
p = self.cls(self.base)
q = p / 'myfile'
self.assertFalse(q.info.exists())
self.assertFalse(q.info.exists(follow_symlinks=False))
q.write_text('hullo')
self.assertFalse(q.info.exists())
self.assertFalse(q.info.exists(follow_symlinks=False))
def test_info_is_dir_caching(self):
p = self.cls(self.base)
q = p / 'mydir'
self.assertFalse(q.info.is_dir())
self.assertFalse(q.info.is_dir(follow_symlinks=False))
q.mkdir()
self.assertFalse(q.info.is_dir())
self.assertFalse(q.info.is_dir(follow_symlinks=False))
def test_info_is_file_caching(self):
p = self.cls(self.base)
q = p / 'myfile'
self.assertFalse(q.info.is_file())
self.assertFalse(q.info.is_file(follow_symlinks=False))
q.write_text('hullo')
self.assertFalse(q.info.is_file())
self.assertFalse(q.info.is_file(follow_symlinks=False))
@needs_symlinks
def test_info_is_symlink_caching(self):
p = self.cls(self.base)