(self, read_func)
| 1272 | self.assertRaises(TypeError, rw.seek, 0.0) |
| 1273 | |
| 1274 | def check_flush_and_read(self, read_func): |
| 1275 | raw = self.BytesIO(b"abcdefghi") |
| 1276 | bufio = self.tp(raw) |
| 1277 | |
| 1278 | self.assertEqual(b"ab", read_func(bufio, 2)) |
| 1279 | bufio.write(b"12") |
| 1280 | self.assertEqual(b"ef", read_func(bufio, 2)) |
| 1281 | self.assertEqual(6, bufio.tell()) |
| 1282 | bufio.flush() |
| 1283 | self.assertEqual(6, bufio.tell()) |
| 1284 | self.assertEqual(b"ghi", read_func(bufio)) |
| 1285 | raw.seek(0, 0) |
| 1286 | raw.write(b"XYZ") |
| 1287 | # flush() resets the read buffer |
| 1288 | bufio.flush() |
| 1289 | bufio.seek(0, 0) |
| 1290 | self.assertEqual(b"XYZ", read_func(bufio, 3)) |
| 1291 | |
| 1292 | def test_flush_and_read(self): |
| 1293 | self.check_flush_and_read(lambda bufio, *args: bufio.read(*args)) |
no test coverage detected