| 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 |