Skip to content

Commit fe0d6fc

Browse files
committed
test common .inferredtype
1 parent e0fddcc commit fe0d6fc

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

pandas/tests/indexes/test_common.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -439,23 +439,21 @@ def test_hasnans_isnans(self, index_flat):
439439

440440
@pytest.mark.filterwarnings(r"ignore:PeriodDtype\[B\] is deprecated:FutureWarning")
441441
@pytest.mark.parametrize("na_position", [None, "middle"])
442-
def test_sort_values_invalid_na_position(index_with_missing, na_position):
443-
if len({type(x) for x in index_with_missing if pd.notna(x)}) > 1:
444-
index_with_missing = index_with_missing.map(str)
442+
def test_sort_values_invalid_na_position(index_with_missing, na_position, request):
443+
if getattr(index_with_missing, "inferred_type", None) in {"mixed", "mixed-integer", "mixed-int-string"}:
444+
request.applymarker(pytest.mark.xfail(reason="Test not supported for mixed type index"))
445445

446446
with pytest.raises(ValueError, match=f"invalid na_position: {na_position}"):
447447
index_with_missing.sort_values(na_position=na_position)
448448

449-
450449
@pytest.mark.filterwarnings(r"ignore:PeriodDtype\[B\] is deprecated:FutureWarning")
451450
@pytest.mark.parametrize("na_position", ["first", "last"])
452451
def test_sort_values_with_missing(index_with_missing, na_position, request):
453452
# GH 35584. Test that sort_values works with missing values,
454453
# sort non-missing and place missing according to na_position
455454

456-
non_na_values = [x for x in index_with_missing if pd.notna(x)]
457-
if len({type(x) for x in non_na_values}) > 1:
458-
index_with_missing = index_with_missing.map(str)
455+
if getattr(index_with_missing, "inferred_type", None) in {"mixed", "mixed-integer", "mixed-int-string"}:
456+
request.applymarker(pytest.mark.xfail(reason="Test not supported for mixed type index"))
459457

460458
if isinstance(index_with_missing, CategoricalIndex):
461459
request.applymarker(

0 commit comments

Comments
 (0)