(tmpdir)
| 2120 | |
| 2121 | @pytest.mark.gzip |
| 2122 | def test_output_stream_file_path_compressed(tmpdir): |
| 2123 | data = b"some test data\n" * 10 + b"eof\n" |
| 2124 | file_path = tmpdir / 'output_stream.gz' |
| 2125 | |
| 2126 | def check_data(file_path, data, **kwargs): |
| 2127 | with pa.output_stream(file_path, **kwargs) as stream: |
| 2128 | stream.write(data) |
| 2129 | with open(str(file_path), 'rb') as f: |
| 2130 | return f.read() |
| 2131 | |
| 2132 | assert gzip.decompress(check_data(file_path, data)) == data |
| 2133 | assert gzip.decompress(check_data(str(file_path), data)) == data |
| 2134 | assert gzip.decompress( |
| 2135 | check_data(pathlib.Path(str(file_path)), data)) == data |
| 2136 | |
| 2137 | assert gzip.decompress( |
| 2138 | check_data(file_path, data, compression='gzip')) == data |
| 2139 | assert check_data(file_path, data, compression=None) == data |
| 2140 | |
| 2141 | with pytest.raises(ValueError, match='Invalid value for compression'): |
| 2142 | assert check_data(file_path, data, compression='rabbit') == data |
| 2143 | |
| 2144 | |
| 2145 | def test_output_stream_file_path_buffered(tmpdir): |
nothing calls this directly
no test coverage detected