Skip to content
Prev Previous commit
Next Next commit
Adapt test_get_handle_pyarrow_compat for pyarrow 19
  • Loading branch information
mroeschke committed Jan 21, 2025
commit 4f0f95d939138406bb81ffa753cfd28f94f456e1
6 changes: 4 additions & 2 deletions pandas/tests/io/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import pandas as pd
import pandas._testing as tm
from pandas.util.version import Version

import pandas.io.common as icom

Expand Down Expand Up @@ -139,6 +140,7 @@ def test_bytesiowrapper_returns_correct_bytes(self):

# Test that pyarrow can handle a file opened with get_handle
def test_get_handle_pyarrow_compat(self):
pa = pytest.importorskip("pyarrow")
pa_csv = pytest.importorskip("pyarrow.csv")

# Test latin1, ucs-2, and ucs-4 chars
Expand All @@ -152,8 +154,8 @@ def test_get_handle_pyarrow_compat(self):
s = StringIO(data)
with icom.get_handle(s, "rb", is_text=False) as handles:
df = pa_csv.read_csv(handles.handle).to_pandas()
# TODO will have to update this when pyarrow' to_pandas() is fixed
expected = expected.astype("object")
if Version(pa.__version__) < Version("19.0"):
expected = expected.astype("object")
tm.assert_frame_equal(df, expected)
assert not s.closed

Expand Down