@@ -438,10 +438,43 @@ def test_hasnans_isnans(self, index_flat):
438
438
439
439
440
440
@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
+ )
445
478
446
479
with pytest .raises (ValueError , match = f"invalid na_position: { na_position } " ):
447
480
index_with_missing .sort_values (na_position = na_position )
0 commit comments