mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
gh-119064: Use os_helper.FakePath instead of pathlib.Path in tests (GH-119065)
This commit is contained in:
parent
0142a2292c
commit
0152dc4ff5
19 changed files with 115 additions and 127 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue