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

Function test_output_stream_file_path_buffered

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

Source from the content-addressed store, hash-verified

2135
2136
2137def test_output_stream_file_path_buffered(tmpdir):
2138 data = b"some test data\n" * 10 + b"eof\n"
2139 file_path = tmpdir / 'output_stream.buffered'
2140
2141 def check_data(file_path, data, **kwargs):
2142 with pa.output_stream(file_path, **kwargs) as stream:
2143 if kwargs.get('buffer_size', 0) > 0:
2144 assert isinstance(stream, pa.BufferedOutputStream)
2145 stream.write(data)
2146 with open(str(file_path), 'rb') as f:
2147 return f.read()
2148
2149 unbuffered_stream = pa.output_stream(file_path, buffer_size=0)
2150 assert isinstance(unbuffered_stream, pa.OSFile)
2151
2152 msg = 'Buffer size must be larger than zero'
2153 with pytest.raises(ValueError, match=msg):
2154 assert check_data(file_path, data, buffer_size=-128) == data
2155
2156 assert check_data(file_path, data, buffer_size=32) == data
2157 assert check_data(file_path, data, buffer_size=1024) == data
2158 assert check_data(str(file_path), data, buffer_size=32) == data
2159
2160 result = check_data(pathlib.Path(str(file_path)), data, buffer_size=32)
2161 assert result == data
2162
2163
2164@pytest.mark.gzip

Callers

nothing calls this directly

Calls 2

check_dataFunction · 0.85
PathMethod · 0.45

Tested by

no test coverage detected