Skip to content

Commit cf20d19

Browse files
committed
test common test_sort_values_with_missing
1 parent 68c8146 commit cf20d19

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

pandas/tests/indexes/test_common.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,13 +482,29 @@ def test_sort_values_invalid_na_position(request, na_position, index_fixture):
482482

483483
@pytest.mark.filterwarnings(r"ignore:PeriodDtype\[B\] is deprecated:FutureWarning")
484484
@pytest.mark.parametrize("na_position", ["first", "last"])
485+
@pytest.mark.parametrize(
486+
"index_with_missing",
487+
[
488+
pytest.param(
489+
"mixed-int-string",
490+
marks=pytest.mark.xfail(reason="Mixed index types"),
491+
),
492+
pytest.param(
493+
"object", marks=pytest.mark.xfail(reason="Object index types")
494+
),
495+
pytest.param("integer", marks=pytest.mark.xfail(reason="Integer index types")),
496+
pytest.param("float", marks=pytest.mark.xfail(reason="Float index types")),
497+
],
498+
)
485499
def test_sort_values_with_missing(index_with_missing, na_position, request):
486500
# GH 35584. Test that sort_values works with missing values,
487501
# sort non-missing and place missing according to na_position
488-
489-
non_na_values = [x for x in index_with_missing if pd.notna(x)]
490-
if len({type(x) for x in non_na_values}) > 1:
491-
index_with_missing = index_with_missing.map(str)
502+
if getattr(index_with_missing, "inferred_type", None) == "mixed":
503+
request.applymarker(
504+
pytest.mark.xfail(
505+
reason="inferred_type not supported in sort_values with missing values"
506+
)
507+
)
492508

493509
if isinstance(index_with_missing, CategoricalIndex):
494510
request.applymarker(

0 commit comments

Comments
 (0)