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

Method test_peek

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

Source from the content-addressed store, hash-verified

478 self.assertEqual(f.read(), uncompressed)
479
480 def test_peek(self):
481 uncompressed = data1 * 200
482 with gzip.GzipFile(self.filename, "wb") as f:
483 f.write(uncompressed)
484
485 def sizes():
486 while True:
487 for n in range(5, 50, 10):
488 yield n
489
490 with gzip.GzipFile(self.filename, "rb") as f:
491 f.max_read_chunk = 33
492 nread = 0
493 for n in sizes():
494 s = f.peek(n)
495 if s == b'':
496 break
497 self.assertEqual(f.read(len(s)), s)
498 nread += len(s)
499 self.assertEqual(f.read(100), b'')
500 self.assertEqual(nread, len(uncompressed))
501
502 def test_textio_readlines(self):
503 # Issue #10791: TextIOWrapper.readlines() fails when wrapping GzipFile.

Callers

nothing calls this directly

Calls 4

writeMethod · 0.45
peekMethod · 0.45
assertEqualMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected