Skip to content

Commit fefcb04

Browse files
avoid pyarrow import error during test collection
1 parent 4d875d1 commit fefcb04

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

pandas/conftest.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,11 +1355,9 @@ def object_dtype(request):
13551355
@pytest.fixture(
13561356
params=[
13571357
np.dtype("object"),
1358-
pd.StringDtype("python"),
1359-
pytest.param(pd.StringDtype("pyarrow"), marks=td.skip_if_no("pyarrow")),
1360-
pytest.param(
1361-
pd.StringDtype("pyarrow", na_value=np.nan), marks=td.skip_if_no("pyarrow")
1362-
),
1358+
("python", pd.NA),
1359+
pytest.param(("pyarrow", pd.NA), marks=td.skip_if_no("pyarrow")),
1360+
pytest.param(("pyarrow", np.nan), marks=td.skip_if_no("pyarrow")),
13631361
],
13641362
ids=[
13651363
"string=object",
@@ -1376,7 +1374,13 @@ def any_string_dtype(request):
13761374
* 'string[pyarrow]' (NA variant)
13771375
* 'str' (NaN variant, with pyarrow)
13781376
"""
1379-
return request.param
1377+
if isinstance(request.param, np.dtype):
1378+
return request.param
1379+
else:
1380+
# need to instantiate the StringDtype here instead of in the params
1381+
# to avoid importing pyarrow during test collection
1382+
storage, na_value = request.param
1383+
return pd.StringDtype(storage, na_value)
13801384

13811385

13821386
@pytest.fixture(params=tm.DATETIME64_DTYPES)

0 commit comments

Comments
 (0)