mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
Simplify tests with data descriptors
This commit is contained in:
parent
d9824ceaa6
commit
85811abea8
2 changed files with 7 additions and 16 deletions
|
|
@ -2503,11 +2503,14 @@ def _generate_local_file_entry(self, arcname, raw_bytes,
|
|||
fz = io.BytesIO()
|
||||
f = Unseekable(fz) if dd else fz
|
||||
cm = (mock.patch.object(struct, 'pack', side_effect=struct_pack_no_dd_sig)
|
||||
if not dd_sig else contextlib.nullcontext())
|
||||
if dd and not dd_sig else contextlib.nullcontext())
|
||||
with zipfile.ZipFile(f, 'w', compression=compression) as zh:
|
||||
with cm:
|
||||
with zh.open(arcname, 'w', force_zip64=force_zip64) as fh:
|
||||
fh.write(raw_bytes)
|
||||
with cm, zh.open(arcname, 'w', force_zip64=force_zip64) as fh:
|
||||
fh.write(raw_bytes)
|
||||
if dd:
|
||||
zi = zh.infolist()[0]
|
||||
self.assertTrue(zi.flag_bits & zipfile._MASK_USE_DATA_DESCRIPTOR,
|
||||
f'data descriptor flag not set: {zi.filename}')
|
||||
fz.seek(0)
|
||||
return fz.read()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue