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:2145–2169  ·  view source on GitHub ↗
(tmpdir)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

check_dataFunction · 0.85
PathMethod · 0.45

Tested by

no test coverage detected