MCPcopy Create free account
hub / github.com/python/cpython / test_read_after_seek

Method test_read_after_seek

Lib/test/test_zipfile/test_core.py:2494–2508  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2492 self.assertEqual(fp.tell(), 0)
2493
2494 def test_read_after_seek(self):
2495 # Issue 102956: Make sure seek(x, os.SEEK_CUR) doesn't break read()
2496 txt = b"Charge men!"
2497 bloc = txt.find(b"men")
2498 with zipfile.ZipFile(TESTFN, "w") as zipf:
2499 zipf.writestr("foo.txt", txt)
2500 with zipfile.ZipFile(TESTFN, mode="r") as zipf:
2501 with zipf.open("foo.txt", "r") as fp:
2502 fp.seek(bloc, os.SEEK_CUR)
2503 self.assertEqual(fp.read(-1), b'men!')
2504 with zipfile.ZipFile(TESTFN, mode="r") as zipf:
2505 with zipf.open("foo.txt", "r") as fp:
2506 fp.read(6)
2507 fp.seek(1, os.SEEK_CUR)
2508 self.assertEqual(fp.read(-1), b'men!')
2509
2510 def test_uncompressed_interleaved_seek_read(self):
2511 # gh-127847: Make sure the position in the archive is correct

Callers

nothing calls this directly

Calls 6

writestrMethod · 0.80
findMethod · 0.45
openMethod · 0.45
seekMethod · 0.45
assertEqualMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected