Skip to content

Commit 014c487

Browse files
TST (string dtype): replace string_storage fixture with explicit storage/na_value keyword arguments for dtype creation (#59375)
1 parent fd0f7bd commit 014c487

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
@@ -1262,6 +1262,24 @@ def string_storage(request):
12621262
return request.param
12631263

12641264

1265+
@pytest.fixture(
1266+
params=[
1267+
("python", pd.NA),
1268+
pytest.param(("pyarrow", pd.NA), marks=td.skip_if_no("pyarrow")),
1269+
pytest.param(("pyarrow", np.nan), marks=td.skip_if_no("pyarrow")),
1270+
]
1271+
)
1272+
def string_dtype_arguments(request):
1273+
"""
1274+
Parametrized fixture for StringDtype storage and na_value.
1275+
1276+
* 'python' + pd.NA
1277+
* 'pyarrow' + pd.NA
1278+
* 'pyarrow' + np.nan
1279+
"""
1280+
return request.param
1281+
1282+
12651283
@pytest.fixture(
12661284
params=[
12671285
"numpy_nullable",

pandas/tests/arrays/string_/test_string.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222

2323

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

2930

3031
@pytest.fixture

pandas/tests/extension/test_string.py

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

5959

6060
@pytest.fixture
61-
def dtype(string_storage):
62-
return StringDtype(storage=string_storage)
61+
def dtype(string_dtype_arguments):
62+
storage, na_value = string_dtype_arguments
63+
return StringDtype(storage=storage, na_value=na_value)
6364

6465

6566
@pytest.fixture

0 commit comments

Comments
 (0)