diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2001-08-09 07:21:56 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2001-08-09 07:21:56 (GMT) |
commit | 8cc965c1fb7da494c5abfb3eef49f017dcdc9939 (patch) | |
tree | 51d8b26474351a7bbfdf2a7e3e4e18a5e9e36998 /Lib/test | |
parent | f30f1fc900d214f11d351daa9ae88013f16cd039 (diff) | |
download | cpython-8cc965c1fb7da494c5abfb3eef49f017dcdc9939.zip cpython-8cc965c1fb7da494c5abfb3eef49f017dcdc9939.tar.gz cpython-8cc965c1fb7da494c5abfb3eef49f017dcdc9939.tar.bz2 |
Patch #448474: Add support for tell() and seek() to gzip.GzipFile.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_gzip.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py index 8ff8c33..6d69c3f 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) |