MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_peek

Method test_peek

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

lenFunction · 0.85
writeMethod · 0.45
peekMethod · 0.45
assertEqualMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected