(tmpdir)
| 2135 | |
| 2136 | |
| 2137 | def 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 |
nothing calls this directly
no test coverage detected