Skip to content

Commit 25f0a7e

Browse files
committed
add comments
1 parent 67f05de commit 25f0a7e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Lib/test/test_zipfile/test_core.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3464,8 +3464,14 @@ def read(self, size=-1):
34643464
# 20000 bytes
34653465
txt = b'0123456789' * 2000
34663466

3467-
# seek length must be greater than ZipExtFile.MIN_READ_SIZE (4096)
3467+
# The seek length must be greater than ZipExtFile.MIN_READ_SIZE (4096)
3468+
# as `ZipExtFile._read2()` reads in blocks of this size and we need to
3469+
# seek out of the buffered data
34683470
min_size = zipfile.ZipExtFile.MIN_READ_SIZE
3471+
self.assertGreaterEqual(10002, min_size)
3472+
self.assertGreaterEqual(5003, min_size)
3473+
# The read length must be less than MIN_READ_SIZE, since we assume that
3474+
# only 1 block is read in the test.
34693475
self.assertGreaterEqual(min_size, 100)
34703476

34713477
with zipfile.ZipFile(sio, "w", compression=zipfile.ZIP_STORED) as zipf:
@@ -3474,6 +3480,9 @@ def read(self, size=-1):
34743480
# check random seek and read on a file
34753481
with zipfile.ZipFile(sio, "r") as zipf:
34763482
with zipf.open("foo.txt", "r") as fp:
3483+
# Test this optimized read hasn't rewound and read from the
3484+
# start of the file (as in the case of the unoptimized path)
3485+
34773486
# forward seek
34783487
old_count = sio.bytes_read
34793488
fp.seek(10002, os.SEEK_CUR)

0 commit comments

Comments
 (0)