gh-119064: Use os_helper.FakePath instead of pathlib.Path in tests (GH-119065)

This commit is contained in:
Serhiy Storchaka 2024-05-16 10:25:10 +03:00 committed by GitHub
parent 0142a2292c
commit 0152dc4ff5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 115 additions and 127 deletions

View file

@ -13,7 +13,7 @@ from ._itertools import Counter
from ._test_params import parameterize, Invoked
from test.support.os_helper import temp_dir
from test.support.os_helper import temp_dir, FakePath
class jaraco:
@ -264,13 +264,13 @@ class TestPath(unittest.TestCase):
zipfile.Path should be constructable from a path-like object
"""
zipfile_ondisk = self.zipfile_ondisk(alpharep)
pathlike = pathlib.Path(str(zipfile_ondisk))
pathlike = FakePath(str(zipfile_ondisk))
zipfile.Path(pathlike)
@pass_alpharep
def test_traverse_pathlike(self, alpharep):
root = zipfile.Path(alpharep)
root / pathlib.Path("a")
root / FakePath("a")
@pass_alpharep
def test_parent(self, alpharep):
@ -539,12 +539,12 @@ class TestPath(unittest.TestCase):
['alpharep', 'path_type', 'subpath'],
itertools.product(
alpharep_generators,
[str, pathlib.Path],
[str, FakePath],
['', 'b/'],
),
)
def test_pickle(self, alpharep, path_type, subpath):
zipfile_ondisk = path_type(self.zipfile_ondisk(alpharep))
zipfile_ondisk = path_type(str(self.zipfile_ondisk(alpharep)))
saved_1 = pickle.dumps(zipfile.Path(zipfile_ondisk, at=subpath))
restored_1 = pickle.loads(saved_1)