-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #288 from python/debt/zip-fixtures
Convert static zip fixtures to proper fixtures derived from disk-based fixtures.
- Loading branch information
Showing
10 changed files
with
83 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
""" | ||
Generate zip test data files. | ||
""" | ||
|
||
import contextlib | ||
import os | ||
import pathlib | ||
import zipfile | ||
|
||
import zipp | ||
|
||
|
||
def make_zip_file(src, dst): | ||
""" | ||
Zip the files in src into a new zipfile at dst. | ||
""" | ||
with zipfile.ZipFile(dst, 'w') as zf: | ||
for src_path, rel in walk(src): | ||
dst_name = src.name / pathlib.PurePosixPath(rel.as_posix()) | ||
zf.write(src_path, dst_name) | ||
zipp.CompleteDirs.inject(zf) | ||
return dst | ||
|
||
|
||
def walk(datapath): | ||
for dirpath, dirnames, filenames in os.walk(datapath): | ||
with contextlib.suppress(ValueError): | ||
dirnames.remove('__pycache__') | ||
for filename in filenames: | ||
res = pathlib.Path(dirpath) / filename | ||
rel = res.relative_to(datapath) | ||
yield res, rel |
Empty file.
Binary file not shown.
Empty file.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ testing = | |
pytest-ruff | ||
|
||
# local | ||
zipp >= 3.17 | ||
|
||
docs = | ||
# upstream | ||
|