@@ -209,19 +209,8 @@ def test_api_per_dtype(self, index_or_series, dtype, any_skipna_inferred_dtype):
209
209
box = index_or_series
210
210
inferred_dtype , values = any_skipna_inferred_dtype
211
211
212
- if dtype == "category" and len (values ) and values [1 ] is pd .NA :
213
- pytest .xfail (reason = "Categorical does not yet support pd.NA" )
214
-
215
212
t = box (values , dtype = dtype ) # explicit dtype to avoid casting
216
213
217
- # TODO: get rid of these xfails
218
- if dtype == "category" and inferred_dtype in ["period" , "interval" ]:
219
- pytest .xfail (
220
- reason = "Conversion to numpy array fails because "
221
- "the ._values-attribute is not a numpy array for "
222
- "PeriodArray/IntervalArray; see GH 23553"
223
- )
224
-
225
214
types_passing_constructor = [
226
215
"string" ,
227
216
"unicode" ,
@@ -247,6 +236,7 @@ def test_api_per_method(
247
236
dtype ,
248
237
any_allowed_skipna_inferred_dtype ,
249
238
any_string_method ,
239
+ request ,
250
240
):
251
241
# this test does not check correctness of the different methods,
252
242
# just that the methods work on the specified (inferred) dtypes,
@@ -258,26 +248,24 @@ def test_api_per_method(
258
248
method_name , args , kwargs = any_string_method
259
249
260
250
# TODO: get rid of these xfails
261
- if (
262
- method_name in ["partition" , "rpartition" ]
263
- and box == Index
264
- and inferred_dtype == "empty"
265
- ):
266
- pytest .xfail (reason = "Method cannot deal with empty Index" )
267
- if (
268
- method_name == "split"
269
- and box == Index
270
- and values .size == 0
271
- and kwargs .get ("expand" , None ) is not None
272
- ):
273
- pytest .xfail (reason = "Split fails on empty Series when expand=True" )
274
- if (
275
- method_name == "get_dummies"
276
- and box == Index
277
- and inferred_dtype == "empty"
278
- and (dtype == object or values .size == 0 )
279
- ):
280
- pytest .xfail (reason = "Need to fortify get_dummies corner cases" )
251
+ reason = None
252
+ if box is Index and values .size == 0 :
253
+ if method_name in ["partition" , "rpartition" ] and kwargs .get (
254
+ "expand" , True
255
+ ):
256
+ reason = "Method cannot deal with empty Index"
257
+ elif method_name == "split" and kwargs .get ("expand" , None ):
258
+ reason = "Split fails on empty Series when expand=True"
259
+ elif method_name == "get_dummies" :
260
+ reason = "Need to fortify get_dummies corner cases"
261
+
262
+ elif box is Index and inferred_dtype == "empty" and dtype == object :
263
+ if method_name == "get_dummies" :
264
+ reason = "Need to fortify get_dummies corner cases"
265
+
266
+ if reason is not None :
267
+ mark = pytest .mark .xfail (reason = reason )
268
+ request .node .add_marker (mark )
281
269
282
270
t = box (values , dtype = dtype ) # explicit dtype to avoid casting
283
271
method = getattr (t .str , method_name )
0 commit comments