Skip to content

Commit 68c8146

Browse files
committed
test_common changed
1 parent d33a6d8 commit 68c8146

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

pandas/tests/indexes/multi/test_setops.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,8 @@ def test_union_duplicates(index, request):
629629
# special case for mixed types
630630
if index.inferred_type == "mixed":
631631
pytest.mark.xfail(
632-
reason="GH#38977 - mixed type union with duplicates is not supported")
632+
reason="GH#38977 - mixed type union with duplicates is not supported"
633+
)
633634

634635
# GH#38977
635636
if index.empty or isinstance(index, (IntervalIndex, CategoricalIndex)):

pandas/tests/indexes/test_common.py

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,43 @@ def test_hasnans_isnans(self, index_flat):
438438

439439

440440
@pytest.mark.filterwarnings(r"ignore:PeriodDtype\[B\] is deprecated:FutureWarning")
441-
@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)
441+
@pytest.mark.parametrize(
442+
"na_position,index_fixture",
443+
[
444+
pytest.param(
445+
None,
446+
"mixed-int-string",
447+
marks=pytest.mark.xfail(reason="Mixed index types"),
448+
),
449+
pytest.param(
450+
"middle",
451+
"mixed-int-string",
452+
marks=pytest.mark.xfail(reason="Mixed index types"),
453+
),
454+
pytest.param(
455+
None, "object", marks=pytest.mark.xfail(reason="Object index types")
456+
),
457+
pytest.param(
458+
"middle", "object", marks=pytest.mark.xfail(reason="Object index types")
459+
),
460+
],
461+
)
462+
def test_sort_values_invalid_na_position(request, na_position, index_fixture):
463+
index_with_missing = request.getfixturevalue(index_fixture)
464+
465+
if getattr(index_with_missing, "inferred_type", None) in [
466+
"mixed",
467+
"mixed-integer",
468+
"object",
469+
"string",
470+
"boolean",
471+
]:
472+
request.applymarker(
473+
pytest.mark.xfail(
474+
reason="inferred_type not supported "
475+
"in sort_values with invalid na_position"
476+
)
477+
)
445478

446479
with pytest.raises(ValueError, match=f"invalid na_position: {na_position}"):
447480
index_with_missing.sort_values(na_position=na_position)

0 commit comments

Comments
 (0)