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

(cherry picked from commit 0152dc4ff5)
This commit is contained in:
Serhiy Storchaka 2024-05-16 11:04:37 +03:00 committed by GitHub
parent ed395f5c0e
commit 33a9f0ce65
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 116 additions and 128 deletions

View file

@ -12,7 +12,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:
@ -271,13 +271,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):
@ -546,12 +546,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)