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

Method check_flush_and_read

Lib/test/test_io.py:2465–2481  ·  view source on GitHub ↗
(self, read_func)

Source from the content-addressed store, hash-verified

2463 self.assertRaises(TypeError, rw.seek, 0.0)
2464
2465 def check_flush_and_read(self, read_func):
2466 raw = self.BytesIO(b"abcdefghi")
2467 bufio = self.tp(raw)
2468
2469 self.assertEqual(b"ab", read_func(bufio, 2))
2470 bufio.write(b"12")
2471 self.assertEqual(b"ef", read_func(bufio, 2))
2472 self.assertEqual(6, bufio.tell())
2473 bufio.flush()
2474 self.assertEqual(6, bufio.tell())
2475 self.assertEqual(b"ghi", read_func(bufio))
2476 raw.seek(0, 0)
2477 raw.write(b"XYZ")
2478 # flush() resets the read buffer
2479 bufio.flush()
2480 bufio.seek(0, 0)
2481 self.assertEqual(b"XYZ", read_func(bufio, 3))
2482
2483 def test_flush_and_read(self):
2484 self.check_flush_and_read(lambda bufio, *args: bufio.read(*args))

Callers 3

test_flush_and_readMethod · 0.95
test_flush_and_peekMethod · 0.95

Calls 7

seekMethod · 0.95
writeMethod · 0.95
assertEqualMethod · 0.45
writeMethod · 0.45
tellMethod · 0.45
flushMethod · 0.45
seekMethod · 0.45

Tested by

no test coverage detected