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