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):
147
147
# See gh-12238
148
148
obj = index_or_series_obj
149
149
150
- # Check for MultiIndex
150
+ # 1. Check for multi-index
151
151
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
153
154
154
- # Check for Index and subtypes
155
+ # 2. Check for Index and subtypes
155
156
if isinstance (obj , Index ):
156
- # Mixed types
157
+ # 2a. Mixed types
157
158
if obj .inferred_type in ["mixed" , "mixed-integer" ]:
158
159
try :
159
160
obj = obj .astype (str )
160
161
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
164
168
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
166
171
167
- # Run tests
172
+ # 3. Run test ONLY if there isn't mixed/complex types
168
173
max_obj = max (obj , default = 0 )
169
174
index = np .searchsorted (obj , max_obj )
170
175
assert 0 <= index <= len (obj )
You can’t perform that action at this time.
0 commit comments