summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorJeffrey Rackauckas <jeffreyrack@gmail.com>2017-08-09 13:37:17 (GMT)
committerPaul Moore <p.f.moore@gmail.com>2017-08-09 13:37:17 (GMT)
commitb811d664defed085d16951088afb579fb649c58d (patch)
tree8d440084c8a7fc1b4cef670cb8c9b772b5a2236a /Lib/test
parent9b0d1d647e3d2ec9d299e5c9f49b02fbbb810a5a (diff)
downloadcpython-b811d664defed085d16951088afb579fb649c58d.zip
cpython-b811d664defed085d16951088afb579fb649c58d.tar.gz
cpython-b811d664defed085d16951088afb579fb649c58d.tar.bz2
bpo-31072: Add filter to zipapp (#3021)
bpo-31072: Add a filter argument to zipapp.create_archive (GH-3021) * Add an include_file argument to allow callers to decide which files to include * Document the new argument
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_zipapp.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_zipapp.py b/Lib/test/test_zipapp.py
index d8d4437..47eed5f 100644
--- a/Lib/test/test_zipapp.py
+++ b/Lib/test/test_zipapp.py
@@ -53,6 +53,23 @@ class ZipAppTest(unittest.TestCase):
self.assertIn('foo/', z.namelist())
self.assertIn('bar/', z.namelist())
+ def test_create_archive_with_include_file(self):
+ # Test packing a directory and using include_file to specify which files to include.
+ def skip_pyc_files(file):
+ return '.pyc' not in str(file)
+ source = self.tmpdir / 'source'
+ source.mkdir()
+ (source / '__main__.py').touch()
+ (source / 'test.py').touch()
+ (source / 'test.pyc').touch()
+ target = self.tmpdir / 'source.pyz'
+
+ zipapp.create_archive(source, target, include_file=skip_pyc_files)
+ with zipfile.ZipFile(target, 'r') as z:
+ self.assertIn('__main__.py', z.namelist())
+ self.assertIn('test.py', z.namelist())
+ self.assertNotIn('test.pyc', z.namelist())
+
def test_create_archive_default_target(self):
# Test packing a directory to the default name.
source = self.tmpdir / 'source'