MCPcopy Create free account
hub / github.com/apache/arrow / test_compressed_input_openfile

Function test_compressed_input_openfile

python/pyarrow/tests/test_io.py:1649–1672  ·  view source on GitHub ↗
(tmpdir)

Source from the content-addressed store, hash-verified

1647
1648@pytest.mark.gzip
1649def test_compressed_input_openfile(tmpdir):
1650 if not Codec.is_available("gzip"):
1651 pytest.skip("gzip support is not built")
1652
1653 data = b"some test data\n" * 10 + b"eof\n"
1654 fn = str(tmpdir / "test_compressed_input_openfile.gz")
1655 with gzip.open(fn, "wb") as f:
1656 f.write(data)
1657
1658 with pa.CompressedInputStream(fn, "gzip") as compressed:
1659 buf = compressed.read_buffer()
1660 assert buf.to_pybytes() == data
1661 assert compressed.closed
1662
1663 with pa.CompressedInputStream(pathlib.Path(fn), "gzip") as compressed:
1664 buf = compressed.read_buffer()
1665 assert buf.to_pybytes() == data
1666 assert compressed.closed
1667
1668 f = open(fn, "rb")
1669 with pa.CompressedInputStream(f, "gzip") as compressed:
1670 buf = compressed.read_buffer()
1671 assert buf.to_pybytes() == data
1672 assert f.closed
1673
1674
1675def check_compressed_concatenated(data, fn, compression):

Callers

nothing calls this directly

Calls 4

read_bufferMethod · 0.80
openMethod · 0.45
writeMethod · 0.45
PathMethod · 0.45

Tested by

no test coverage detected