Skip to content

Commit c307074

Browse files
TST (string dtype): add explicit object vs str dtype to index fixture (pandas-dev#60116)
(cherry picked from commit 7bd594c)
1 parent ba3e933 commit c307074

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

pandas/conftest.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,8 @@ def _create_mi_with_dt64tz_level():
615615

616616

617617
indices_dict = {
618-
"string": Index([f"pandas_{i}" for i in range(100)]),
618+
"object": Index([f"pandas_{i}" for i in range(100)], dtype=object),
619+
"string": Index([f"pandas_{i}" for i in range(100)], dtype="str"),
619620
"datetime": date_range("2020-01-01", periods=100),
620621
"datetime-tz": date_range("2020-01-01", periods=100, tz="US/Pacific"),
621622
"period": period_range("2020-01-01", periods=100, freq="D"),

pandas/tests/indexes/test_any_index.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_map_identity_mapping(index, request):
4545
# GH#12766
4646

4747
result = index.map(lambda x: x)
48-
if index.dtype == object and result.dtype == bool:
48+
if index.dtype == object and result.dtype in [bool, "string"]:
4949
assert (index == result).all()
5050
# TODO: could work that into the 'exact="equiv"'?
5151
return # FIXME: doesn't belong in this file anymore!

pandas/tests/indexes/test_old_base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def test_ensure_copied_data(self, index):
260260
"RangeIndex cannot be initialized from data, "
261261
"MultiIndex and CategoricalIndex are tested separately"
262262
)
263-
elif index.dtype == object and index.inferred_type == "boolean":
263+
elif index.dtype == object and index.inferred_type in ["boolean", "string"]:
264264
init_kwargs["dtype"] = index.dtype
265265

266266
index_type = type(index)

pandas/tests/indexes/test_setops.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,13 @@ def test_difference_base(self, sort, index):
293293
first.difference([1, 2, 3], sort)
294294

295295
@pytest.mark.filterwarnings(r"ignore:PeriodDtype\[B\] is deprecated:FutureWarning")
296-
def test_symmetric_difference(self, index):
296+
def test_symmetric_difference(self, index, using_infer_string, request):
297+
if (
298+
using_infer_string
299+
and index.dtype == "object"
300+
and index.inferred_type == "string"
301+
):
302+
request.applymarker(pytest.mark.xfail(reason="TODO: infer_string"))
297303
if isinstance(index, CategoricalIndex):
298304
pytest.skip(f"Not relevant for {type(index).__name__}")
299305
if len(index) < 2:

pandas/tests/test_algos.py

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def test_factorize_complex(self):
6565
expected_uniques = np.array([(1 + 0j), (2 + 0j), (2 + 1j)], dtype=object)
6666
tm.assert_numpy_array_equal(uniques, expected_uniques)
6767

68+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
6869
@pytest.mark.parametrize("sort", [True, False])
6970
def test_factorize(self, index_or_series_obj, sort):
7071
obj = index_or_series_obj

0 commit comments

Comments
 (0)