summaryrefslogtreecommitdiff
path: root/Lib/test/test_importlib/update-zips.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2022-07-24 20:53:10 -0400
committerGitHub <noreply@github.com>2022-07-24 20:53:10 -0400
commit3e718cf880e8994d76f6296a502497c16a956644 (patch)
tree4eeeeae42bdb6138b08c5f20711a8b426db606da /Lib/test/test_importlib/update-zips.py
parent9007dec606b790c05e158e588b696f3c210c2795 (diff)
downloadcpython-git-3e718cf880e8994d76f6296a502497c16a956644.tar.gz
gh-95218: Move tests for importlib.resources into test_importlib.resources. (#95219)
* gh-95218: Move tests for importlib.resources into test_importlib.resources. * Also update makefile * Include test_importlib/resources in code ownership rule.
Diffstat (limited to 'Lib/test/test_importlib/update-zips.py')
-rwxr-xr-xLib/test/test_importlib/update-zips.py53
1 files changed, 0 insertions, 53 deletions
diff --git a/Lib/test/test_importlib/update-zips.py b/Lib/test/test_importlib/update-zips.py
deleted file mode 100755
index 231334aa7e..0000000000
--- a/Lib/test/test_importlib/update-zips.py
+++ /dev/null
@@ -1,53 +0,0 @@
-"""
-Generate the zip test data files.
-
-Run to build the tests/zipdataNN/ziptestdata.zip files from
-files in tests/dataNN.
-
-Replaces the file with the working copy, but does commit anything
-to the source repo.
-"""
-
-import contextlib
-import os
-import pathlib
-import zipfile
-
-
-def main():
- """
- >>> from unittest import mock
- >>> monkeypatch = getfixture('monkeypatch')
- >>> monkeypatch.setattr(zipfile, 'ZipFile', mock.MagicMock())
- >>> print(); main() # print workaround for bpo-32509
- <BLANKLINE>
- ...data01... -> ziptestdata/...
- ...
- ...data02... -> ziptestdata/...
- ...
- """
- suffixes = '01', '02'
- tuple(map(generate, suffixes))
-
-
-def generate(suffix):
- root = pathlib.Path(__file__).parent.relative_to(os.getcwd())
- zfpath = root / f'zipdata{suffix}/ziptestdata.zip'
- with zipfile.ZipFile(zfpath, 'w') as zf:
- for src, rel in walk(root / f'data{suffix}'):
- dst = 'ziptestdata' / pathlib.PurePosixPath(rel.as_posix())
- print(src, '->', dst)
- zf.write(src, 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
-
-
-__name__ == '__main__' and main()