MCPcopy Index your code
hub / github.com/python/cpython / test_seek_read

Method test_seek_read

Lib/test/test_gzip.py:286–303  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

284 if L == []: break
285
286 def test_seek_read(self):
287 self.test_write()
288 # Try seek, read test
289
290 with gzip.GzipFile(self.filename) as f:
291 while 1:
292 oldpos = f.tell()
293 line1 = f.readline()
294 if not line1: break
295 newpos = f.tell()
296 f.seek(oldpos) # negative seek
297 if len(line1)>10:
298 amount = 10
299 else:
300 amount = len(line1)
301 line2 = f.read(amount)
302 self.assertEqual(line1[:amount], line2)
303 f.seek(newpos) # positive seek
304
305 def test_seek_whence(self):
306 self.test_write()

Callers

nothing calls this directly

Calls 6

test_writeMethod · 0.95
tellMethod · 0.45
readlineMethod · 0.45
seekMethod · 0.45
readMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected