mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
gh-132933: zipapp - apply the filter when creating the list of files to add (gh-132934)
This commit is contained in:
parent
a64fdc7513
commit
698c6e3a0c
3 changed files with 21 additions and 5 deletions
|
@ -113,6 +113,19 @@ class ZipAppTest(unittest.TestCase):
|
|||
with self.assertRaises(zipapp.ZipAppError):
|
||||
zipapp.create_archive(source, target)
|
||||
|
||||
def test_target_overwrites_filtered_source_file(self):
|
||||
# If there's a filter that excludes the target,
|
||||
# the overwrite check shouldn't trigger.
|
||||
source = self.tmpdir
|
||||
(source / '__main__.py').touch()
|
||||
target = source / 'target.pyz'
|
||||
target.touch()
|
||||
pyz_filter = lambda p: not p.match('*.pyz')
|
||||
zipapp.create_archive(source, target, filter=pyz_filter)
|
||||
with zipfile.ZipFile(target, 'r') as z:
|
||||
self.assertEqual(len(z.namelist()), 1)
|
||||
self.assertIn('__main__.py', z.namelist())
|
||||
|
||||
def test_create_archive_filter_exclude_dir(self):
|
||||
# Test packing a directory and using a filter to exclude a
|
||||
# subdirectory (ensures that the path supplied to include
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue