8000 TST (string dtype): change any_string_dtype fixture to use actual dtype instances by jorisvandenbossche · Pull Request #59345 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

TST (string dtype): change any_string_dtype fixture to use actual dtype instances #59345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Prev Previous commit
Next Next commit
avoid pyarrow import error during test collection
  • Loading branch information
jorisvandenbossche committed Jul 30, 2024
commit fefcb0436ceb62110de221282279efbd5364e60b
16 changes: 10 additions & 6 deletions pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1355,11 +1355,9 @@ def object_dtype(request):
@pytest.fixture(
params=[
np.dtype("object"),
pd.StringDtype("python"),
pytest.param(pd.StringDtype("pyarrow"), marks=td.skip_if_no("pyarrow")),
pytest.param(
pd.StringDtype("pyarrow", na_value=np.nan), marks=td.skip_if_no("pyarrow")
),
("python", pd.NA),
pytest.param(("pyarrow", pd.NA), marks=td.skip_if_no("pyarrow")),
pytest.param(("pyarrow", np.nan), marks=td.skip_if_no("pyarrow")),
],
ids=[
"string=object",
Expand All @@ -1376,7 +1374,13 @@ def any_string_dtype(request):
* 'string[pyarrow]' (NA variant)
* 'str' (NaN variant, with pyarrow)
"""
return request.param
if isinstance(request.param, np.dtype):
return request.param
else:
# need to instantiate the StringDtype here instead of in the params
# to avoid importing pyarrow during test collection
storage, na_value = request.param
return pd.StringDtype(storage, na_value)


@pytest.fixture(params=tm.DATETIME64_DTYPES)
Expand Down
Loading
0