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

Function test_input_stream_file_path_buffered

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

Source from the content-addressed store, hash-verified

1974
1975
1976def test_input_stream_file_path_buffered(tmpdir):
1977 data = b"some test data\n" * 10 + b"eof\n"
1978 file_path = tmpdir / 'input_stream.buffered'
1979 with open(str(file_path), 'wb') as f:
1980 f.write(data)
1981
1982 stream = pa.input_stream(file_path, buffer_size=32)
1983 assert isinstance(stream, pa.BufferedInputStream)
1984 assert stream.read() == data
1985 stream = pa.input_stream(str(file_path), buffer_size=64)
1986 assert isinstance(stream, pa.BufferedInputStream)
1987 assert stream.read() == data
1988 stream = pa.input_stream(pathlib.Path(str(file_path)), buffer_size=1024)
1989 assert isinstance(stream, pa.BufferedInputStream)
1990 assert stream.read() == data
1991
1992 unbuffered_stream = pa.input_stream(file_path, buffer_size=0)
1993 assert isinstance(unbuffered_stream, pa.OSFile)
1994
1995 msg = 'Buffer size must be larger than zero'
1996 with pytest.raises(ValueError, match=msg):
1997 pa.input_stream(file_path, buffer_size=-1)
1998 with pytest.raises(TypeError):
1999 pa.input_stream(file_path, buffer_size='million')
2000
2001
2002@pytest.mark.gzip

Callers

nothing calls this directly

Calls 3

writeMethod · 0.45
readMethod · 0.45
PathMethod · 0.45

Tested by

no test coverage detected