Skip to content

Commit 2c34891

Browse files
authored
rename and refine comments
1 parent f3137e5 commit 2c34891

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Lib/test/test_zipfile/test_core.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3447,8 +3447,8 @@ def test_too_short(self):
34473447
self.assertEqual(
34483448
b"zzz", zipfile._Extra.strip(b"zzz", (self.ZIP64_EXTRA,)))
34493449

3450-
class StoreSeekReadTest(unittest.TestCase):
3451-
def test_store_seek_read(self):
3450+
class StoredZipExtFileRandomAccessTest(unittest.TestCase):
3451+
def test_random_access(self):
34523452
from _pyio import BytesIO
34533453
class StatIO(BytesIO):
34543454
def __init__(self):
@@ -3464,36 +3464,36 @@ def get_bytes_read(self):
34643464
return self.bytes_read
34653465

34663466
sio = StatIO()
3467+
# 100000 bytes
34673468
txt = b'0123456789'*10000
34683469

34693470
# Check seek on a file
3470-
with zipfile.ZipFile(sio, "w") as zipf:
3471-
zipf.writestr("foo.txt", txt) # 100000 bytes
3471+
with zipfile.ZipFile(sio, "w", compression=zipfile.ZIP_STORED) as zipf:
3472+
zipf.writestr("foo.txt", txt)
34723473

34733474
with zipfile.ZipFile(sio, "r") as zipf:
34743475
with zipf.open("foo.txt", "r") as fp:
34753476
br = sio.get_bytes_read()
34763477
fp.seek(50000, os.SEEK_CUR)
3477-
self.assertEqual(sio.get_bytes_read() - br, 0, 'seek produces extra read!')
3478+
self.assertEqual(sio.get_bytes_read() - br, 0, 'seek produces redundant read!')
34783479

34793480
b = fp.read(100)
34803481
self.assertEqual(b, txt[:100])
34813482

3483+
# seek length must be greater than ZipExtFile.MIN_READ_SIZE (4096)
34823484
# backward seek
3483-
# seek length must be more than MIN_READ_SIZE (4096)
34843485
br = sio.get_bytes_read()
34853486
fp.seek(5000, os.SEEK_CUR)
34863487
b = fp.read(100)
34873488
self.assertEqual(b, txt[50000:50100])
3488-
self.assertLessEqual(sio.get_bytes_read() - br, 4096, 'read more bytes after backward seek!')
3489+
self.assertLessEqual(sio.get_bytes_read() - br, 4096, 'read redundant bytes during backward seek!')
34893490

34903491
# forward seek
3491-
# seek length must be more than MIN_READ_SIZE (4096)
34923492
br = sio.get_bytes_read()
34933493
fp.seek(-40000, os.SEEK_CUR)
34943494
b = fp.read(100)
34953495
self.assertEqual(b, txt[10100:10200])
3496-
self.assertLessEqual(sio.get_bytes_read() - br, 4096, 'read more bytes after forward seek!')
3496+
self.assertLessEqual(sio.get_bytes_read() - br, 4096, 'read redundant bytes during forward seek!')
34973497

34983498
if __name__ == "__main__":
34993499
unittest.main()

0 commit comments

Comments
 (0)