Skip to content

Commit

Permalink
TST (string dtype): replace string_storage fixture with explicit stor…
Browse files Browse the repository at this point in the history
…age/na_value keyword arguments for dtype creation (pandas-dev#59375)
  • Loading branch information
jorisvandenbossche authored and WillAyd committed Aug 15, 2024
1 parent 34b1a9f commit 8fe7308
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
18 changes: 18 additions & 0 deletions pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,24 @@ def string_storage(request):
return request.param


@pytest.fixture(
params=[
("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")),
]
)
def string_dtype_arguments(request):
"""
Parametrized fixture for StringDtype storage and na_value.
* 'python' + pd.NA
* 'pyarrow' + pd.NA
* 'pyarrow' + np.nan
"""
return request.param


@pytest.fixture(
params=[
"numpy_nullable",
Expand Down
7 changes: 4 additions & 3 deletions pandas/tests/arrays/string_/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@


@pytest.fixture
def dtype(string_storage):
"""Fixture giving StringDtype from parametrized 'string_storage'"""
return pd.StringDtype(storage=string_storage)
def dtype(string_dtype_arguments):
"""Fixture giving StringDtype from parametrized storage and na_value arguments"""
storage, na_value = string_dtype_arguments
return pd.StringDtype(storage=storage, na_value=na_value)


@pytest.fixture
Expand Down
5 changes: 3 additions & 2 deletions pandas/tests/extension/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ def chunked(request):


@pytest.fixture
def dtype(string_storage):
return StringDtype(storage=string_storage)
def dtype(string_dtype_arguments):
storage, na_value = string_dtype_arguments
return StringDtype(storage=storage, na_value=na_value)


@pytest.fixture
Expand Down

0 comments on commit 8fe7308

Please sign in to comment.