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

Method test_seeking

Lib/test/test_io/test_textio.py:599–614  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

597 f.close()
598
599 def test_seeking(self):
600 chunk_size = _default_chunk_size()
601 prefix_size = chunk_size - 2
602 u_prefix = "a" * prefix_size
603 prefix = bytes(u_prefix.encode("utf-8"))
604 self.assertEqual(len(u_prefix), len(prefix))
605 u_suffix = "\u8888\n"
606 suffix = bytes(u_suffix.encode("utf-8"))
607 line = prefix + suffix
608 with self.open(os_helper.TESTFN, "wb") as f:
609 f.write(line*2)
610 with self.open(os_helper.TESTFN, "r", encoding="utf-8") as f:
611 s = f.read(prefix_size)
612 self.assertEqual(s, str(prefix, "ascii"))
613 self.assertEqual(f.tell(), prefix_size)
614 self.assertEqual(f.readline(), u_suffix)
615
616 def test_seeking_too(self):
617 # Regression test for a specific bug

Callers

nothing calls this directly

Calls 9

_default_chunk_sizeFunction · 0.85
strFunction · 0.85
encodeMethod · 0.45
assertEqualMethod · 0.45
openMethod · 0.45
writeMethod · 0.45
readMethod · 0.45
tellMethod · 0.45
readlineMethod · 0.45

Tested by

no test coverage detected