MCPcopy Create free account
hub / github.com/apache/arrow / test_native_file_read1

Function test_native_file_read1

python/pyarrow/tests/test_io.py:1483–1503  ·  view source on GitHub ↗
(tmpdir)

Source from the content-addressed store, hash-verified

1481
1482
1483def test_native_file_read1(tmpdir):
1484 # ARROW-16272: read1() should not exhaust the input stream if there
1485 # is a large amount of data remaining.
1486 data = b'123\n' * 1_000_000
1487 path = str(tmpdir / 'largefile.txt')
1488 with open(path, 'wb') as f:
1489 f.write(data)
1490
1491 chunks = []
1492 with pa.OSFile(path, mode='rb') as f:
1493 while True:
1494 b = f.read1()
1495 assert len(b) < len(data)
1496 chunks.append(b)
1497 b = f.read1(30_000)
1498 assert len(b) <= 30_000
1499 chunks.append(b)
1500 if not b:
1501 break
1502
1503 assert b"".join(chunks) == data
1504
1505
1506@pytest.mark.pandas

Callers

nothing calls this directly

Calls 4

lenFunction · 0.85
writeMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected