(tmpdir)
| 2110 | |
| 2111 | |
| 2112 | def test_output_stream_file_path_buffered(tmpdir): |
| 2113 | data = b"some test data\n" * 10 + b"eof\n" |
| 2114 | file_path = tmpdir / 'output_stream.buffered' |
| 2115 | |
| 2116 | def check_data(file_path, data, **kwargs): |
| 2117 | with pa.output_stream(file_path, **kwargs) as stream: |
| 2118 | if kwargs.get('buffer_size', 0) > 0: |
| 2119 | assert isinstance(stream, pa.BufferedOutputStream) |
| 2120 | stream.write(data) |
| 2121 | with open(str(file_path), 'rb') as f: |
| 2122 | return f.read() |
| 2123 | |
| 2124 | unbuffered_stream = pa.output_stream(file_path, buffer_size=0) |
| 2125 | assert isinstance(unbuffered_stream, pa.OSFile) |
| 2126 | |
| 2127 | msg = 'Buffer size must be larger than zero' |
| 2128 | with pytest.raises(ValueError, match=msg): |
| 2129 | assert check_data(file_path, data, buffer_size=-128) == data |
| 2130 | |
| 2131 | assert check_data(file_path, data, buffer_size=32) == data |
| 2132 | assert check_data(file_path, data, buffer_size=1024) == data |
| 2133 | assert check_data(str(file_path), data, buffer_size=32) == data |
| 2134 | |
| 2135 | result = check_data(pathlib.Path(str(file_path)), data, buffer_size=32) |
| 2136 | assert result == data |
| 2137 | |
| 2138 | |
| 2139 | @pytest.mark.gzip |
nothing calls this directly
no test coverage detected