Skip to content

Commit 0d12b44

Browse files
TST (string dtype): replace string_storage fixture with explicit storage/na_value keyword arguments for dtype creation (#59375)
1 parent 4b4c86e commit 0d12b44

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

pandas/conftest.py

+18
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,24 @@ def string_storage(request):
13101310
return request.param
13111311

13121312

1313+
@pytest.fixture(
1314+
params=[
1315+
("python", pd.NA),
1316+
pytest.param(("pyarrow", pd.NA), marks=td.skip_if_no("pyarrow")),
1317+
pytest.param(("pyarrow", np.nan), marks=td.skip_if_no("pyarrow")),
1318+
]
1319+
)
1320+
def string_dtype_arguments(request):
1321+
"""
1322+
Parametrized fixture for StringDtype storage and na_value.
1323+
1324+
* 'python' + pd.NA
1325+
* 'pyarrow' + pd.NA
1326+
* 'pyarrow' + np.nan
1327+
"""
1328+
return request.param
1329+
1330+
13131331
@pytest.fixture(
13141332
params=[
13151333
"numpy_nullable",

pandas/tests/arrays/string_/test_string.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323

2424

2525
@pytest.fixture
26-
def dtype(string_storage):
27-
"""Fixture giving StringDtype from parametrized 'string_storage'"""
28-
return pd.StringDtype(storage=string_storage)
26+
def dtype(string_dtype_arguments):
27+
"""Fixture giving StringDtype from parametrized storage and na_value arguments"""
28+
storage, na_value = string_dtype_arguments
29+
return pd.StringDtype(storage=storage, na_value=na_value)
2930

3031

3132
@pytest.fixture

pandas/tests/extension/test_string.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ def chunked(request):
5959

6060

6161
@pytest.fixture
62-
def dtype(string_storage):
63-
return StringDtype(storage=string_storage)
62+
def dtype(string_dtype_arguments):
63+
storage, na_value = string_dtype_arguments
64+
return StringDtype(storage=storage, na_value=na_value)
6465

6566

6667
@pytest.fixture

0 commit comments

Comments
 (0)