(tmpdir)
| 2143 | |
| 2144 | |
| 2145 | def 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 |
nothing calls this directly
no test coverage detected