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

Function test_compressed_input_openfile

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

Source from the content-addressed store, hash-verified

1614
1615@pytest.mark.gzip
1616def test_compressed_input_openfile(tmpdir):
1617 if not Codec.is_available("gzip"):
1618 pytest.skip("gzip support is not built")
1619
1620 data = b"some test data\n" * 10 + b"eof\n"
1621 fn = str(tmpdir / "test_compressed_input_openfile.gz")
1622 with gzip.open(fn, "wb") as f:
1623 f.write(data)
1624
1625 with pa.CompressedInputStream(fn, "gzip") as compressed:
1626 buf = compressed.read_buffer()
1627 assert buf.to_pybytes() == data
1628 assert compressed.closed
1629
1630 with pa.CompressedInputStream(pathlib.Path(fn), "gzip") as compressed:
1631 buf = compressed.read_buffer()
1632 assert buf.to_pybytes() == data
1633 assert compressed.closed
1634
1635 f = open(fn, "rb")
1636 with pa.CompressedInputStream(f, "gzip") as compressed:
1637 buf = compressed.read_buffer()
1638 assert buf.to_pybytes() == data
1639 assert f.closed
1640
1641
1642def 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