From 8cc965c1fb7da494c5abfb3eef49f017dcdc9939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Thu, 9 Aug 2001 07:21:56 +0000 Subject: Patch #448474: Add support for tell() and seek() to gzip.GzipFile. --- Lib/test/test_gzip.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'Lib/test/test_gzip.py') diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py index 8ff8c337e7..6d69c3f281 100644 --- a/Lib/test/test_gzip.py +++ b/Lib/test/test_gzip.py @@ -50,5 +50,29 @@ while 1: if L == []: break f.close() +# Try seek, read test + +f = gzip.GzipFile(filename) +while 1: + oldpos = f.tell() + line1 = f.readline() + if not line1: break + newpos = f.tell() + f.seek(oldpos) # negative seek + if len(line1)>10: + amount = 10 + else: + amount = len(line1) + line2 = f.read(amount) + verify(line1[:amount] == line2) + f.seek(newpos) # positive seek +f.close() + +# Try seek, write test +f = gzip.GzipFile(filename, 'w') +for pos in range(0, 256, 16): + f.seek(pos) + f.write('GZ\n') +f.close() os.unlink(filename) -- cgit v1.2.1