summaryrefslogtreecommitdiff
path: root/Lib/test/test_gzip.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2001-08-09 07:21:56 +0000
committerMartin v. Löwis <martin@v.loewis.de>2001-08-09 07:21:56 +0000
commit8cc965c1fb7da494c5abfb3eef49f017dcdc9939 (patch)
tree51d8b26474351a7bbfdf2a7e3e4e18a5e9e36998 /Lib/test/test_gzip.py
parentf30f1fc900d214f11d351daa9ae88013f16cd039 (diff)
downloadcpython-git-8cc965c1fb7da494c5abfb3eef49f017dcdc9939.tar.gz
Patch #448474: Add support for tell() and seek() to gzip.GzipFile.
Diffstat (limited to 'Lib/test/test_gzip.py')
-rw-r--r--Lib/test/test_gzip.py24
1 files changed, 24 insertions, 0 deletions
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)