Skip to content

Commit 46099a0

Browse files
committed
fixed tests to fail gracefully if pyarrow is not installed in ci/cd
1 parent 0e261ee commit 46099a0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pandas/tests/dtypes/test_dtypes.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,26 +1104,29 @@ def test_update_dtype_errors(self, bad_dtype):
11041104
with pytest.raises(ValueError, match=msg):
11051105
dtype.update_dtype(bad_dtype)
11061106

1107+
import pytest
1108+
11071109
class TestArrowDtype(Base):
11081110
@pytest.fixture
11091111
def dtype(self):
11101112
"""Fixture for ArrowDtype."""
1111-
import pyarrow as pa
1113+
pa = pytest.importorskip("pyarrow")
11121114
return ArrowDtype(pa.timestamp("ns", tz="UTC"))
11131115

11141116
def test_numpy_dtype_preserves_timezone(self, dtype):
1117+
pa = pytest.importorskip("pyarrow")
11151118
# Test timezone-aware timestamp
11161119
assert dtype.numpy_dtype == dtype.pyarrow_dtype.to_pandas_dtype()
11171120

11181121
def test_numpy_dtype_naive_timestamp(self):
1119-
import pyarrow as pa
1122+
pa = pytest.importorskip("pyarrow")
11201123
arrow_type = pa.timestamp("ns")
11211124
dtype = ArrowDtype(arrow_type)
11221125
assert dtype.numpy_dtype == pa.timestamp("ns").to_pandas_dtype()
11231126

11241127
@pytest.mark.parametrize("tz", ["UTC", "America/New_York", None])
11251128
def test_numpy_dtype_with_varied_timezones(self, tz):
1126-
import pyarrow as pa
1129+
pa = pytest.importorskip("pyarrow")
11271130
arrow_type = pa.timestamp("ns", tz=tz)
11281131
dtype = ArrowDtype(arrow_type)
11291132
if tz:

0 commit comments

Comments
 (0)