Skip to content

Commit a5db266

Browse files
committed
gh-152190: Improve coding style and docstrings
1 parent 5335be0 commit a5db266

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

Lib/test/test_zipfile64.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ def test_strip_removed_large_file_with_dd(self):
197197
self.assertFalse(f.closed)
198198

199199
def test_strip_removed_large_file_with_dd_no_sig(self):
200-
"""Should scan for the data descriptor (without signature) of a removed
201-
large file without causing a memory issue."""
200+
"""Should scan for the unsigned data descriptor of a removed large file
201+
without causing a memory issue."""
202202
# Reduce data scale for this test, as it's especially slow...
203203
self.datacount = 30*1024**2 // len(self.data)
204204

@@ -208,11 +208,11 @@ def test_strip_removed_large_file_with_dd_no_sig(self):
208208
file = 'file.txt'
209209
file1 = 'largefile.txt'
210210
data = b'Sed ut perspiciatis unde omnis iste natus error sit voluptatem'
211-
with mock.patch('zipfile.struct.pack', side_effect=struct_pack_no_dd_sig):
212-
with zipfile.ZipFile(Unseekable(f), 'w') as zh:
213-
with zh.open(file1, 'w', force_zip64=True) as fh:
214-
self._write_large_file(fh)
215-
zh.writestr(file, data)
211+
with mock.patch('zipfile.struct.pack', side_effect=struct_pack_no_dd_sig), \
212+
zipfile.ZipFile(Unseekable(f), 'w') as zh:
213+
with zh.open(file1, 'w', force_zip64=True) as fh:
214+
self._write_large_file(fh)
215+
zh.writestr(file, data)
216216

217217
with self.assert_memory_usage(self.allowed_memory), \
218218
zipfile.ZipFile(f, 'a') as zh:
@@ -226,20 +226,19 @@ def test_strip_removed_large_file_with_dd_no_sig(self):
226226

227227
@requires_zlib()
228228
def test_strip_removed_large_file_with_dd_no_sig_by_decompression(self):
229-
"""Should scan for the data descriptor (without signature) of a removed
230-
large file without causing a memory issue."""
229+
"""Should scan for the unsigned data descriptor (via tracing compressed
230+
block end) of a removed large file without causing a memory issue."""
231231
# Try the temp file. If we do TESTFN2, then it hogs
232232
# gigabytes of disk space for the duration of the test.
233233
with TemporaryFile() as f:
234234
file = 'file.txt'
235235
file1 = 'largefile.txt'
236236
data = b'Sed ut perspiciatis unde omnis iste natus error sit voluptatem'
237-
with mock.patch('zipfile.struct.pack', side_effect=struct_pack_no_dd_sig):
238-
with zipfile.ZipFile(Unseekable(f), 'w',
239-
compression=zipfile.ZIP_DEFLATED) as zh:
240-
with zh.open(file1, 'w', force_zip64=True) as fh:
241-
self._write_large_file(fh)
242-
zh.writestr(file, data)
237+
with mock.patch('zipfile.struct.pack', side_effect=struct_pack_no_dd_sig), \
238+
zipfile.ZipFile(Unseekable(f), 'w', compression=zipfile.ZIP_DEFLATED) as zh:
239+
with zh.open(file1, 'w', force_zip64=True) as fh:
240+
self._write_large_file(fh)
241+
zh.writestr(file, data)
243242

244243
with self.assert_memory_usage(self.allowed_memory), \
245244
zipfile.ZipFile(f, 'a') as zh:

0 commit comments

Comments
 (0)