File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -147,24 +147,29 @@ def test_searchsorted(request, index_or_series_obj):
147147 # See gh-12238
148148 obj = index_or_series_obj
149149
150- # Check for MultiIndex
150+ # 1. Check for multi-index
151151 if isinstance (obj , pd .MultiIndex ):
152- pytest .xfail ("np.searchsorted doesn't work on pd.MultiIndex: GH 14833" )
152+ request .applymarker (pytest .mark .xfail (reason = "GH 14833" , strict = False ))
153+ return
153154
154- # Check for Index and subtypes
155+ # 2. Check for Index and subtypes
155156 if isinstance (obj , Index ):
156- # Mixed types
157+ # 2a. Mixed types
157158 if obj .inferred_type in ["mixed" , "mixed-integer" ]:
158159 try :
159160 obj = obj .astype (str )
160161 except (TypeError , ValueError ):
161- pytest .xfail ("Cannot compare mixed types (str and int)" )
162-
163- # Complex types
162+ request .applymarker (
163+ pytest .mark .xfail (reason = "Mixed types" , strict = False )
164+ )
165+ return
166+
167+ # 2b. Complex types
164168 elif obj .dtype .kind == "c" :
165- pytest .xfail ("Complex objects are not comparable" )
169+ request .applymarker (pytest .mark .xfail (reason = "Complex types" , strict = False ))
170+ return
166171
167- # Run tests
172+ # 3. Run test ONLY if there isn't mixed/complex types
168173 max_obj = max (obj , default = 0 )
169174 index = np .searchsorted (obj , max_obj )
170175 assert 0 <= index <= len (obj )
You can’t perform that action at this time.
0 commit comments