@@ -217,15 +217,18 @@ def test_comparison_methods_scalar_pd_na(comparison_op, dtype):
217
217
tm .assert_extension_array_equal (result , expected )
218
218
219
219
220
- def test_comparison_methods_scalar_not_string (comparison_op , dtype , request ):
220
+ def test_comparison_methods_scalar_not_string (comparison_op , dtype ):
221
221
op_name = f"__{ comparison_op .__name__ } __"
222
- if op_name not in ["__eq__" , "__ne__" ]:
223
- reason = "comparison op not supported between instances of 'str' and 'int'"
224
- mark = pytest .mark .xfail (raises = TypeError , reason = reason )
225
- request .node .add_marker (mark )
226
222
227
223
a = pd .array (["a" , None , "c" ], dtype = dtype )
228
224
other = 42
225
+
226
+ if op_name not in ["__eq__" , "__ne__" ]:
227
+ with pytest .raises (TypeError , match = "not supported between" ):
228
+ getattr (a , op_name )(other )
229
+
230
+ return
231
+
229
232
result = getattr (a , op_name )(other )
230
233
expected_data = {"__eq__" : [False , None , False ], "__ne__" : [True , None , True ]}[
231
234
op_name
@@ -234,12 +237,7 @@ def test_comparison_methods_scalar_not_string(comparison_op, dtype, request):
234
237
tm .assert_extension_array_equal (result , expected )
235
238
236
239
237
- def test_comparison_methods_array (comparison_op , dtype , request ):
238
- if dtype .storage == "pyarrow" :
239
- mark = pytest .mark .xfail (
240
- raises = AssertionError , reason = "left is not an ExtensionArray"
241
- )
242
- request .node .add_marker (mark )
240
+ def test_comparison_methods_array (comparison_op , dtype ):
243
241
244
242
op_name = f"__{ comparison_op .__name__ } __"
245
243
@@ -340,6 +338,17 @@ def test_reduce(skipna, dtype):
340
338
assert result == "abc"
341
339
342
340
341
+ @pytest .mark .parametrize ("skipna" , [True , False ])
342
+ @pytest .mark .xfail (reason = "Not implemented StringArray.sum" )
343
+ def test_reduce_missing (skipna , dtype ):
344
+ arr = pd .Series ([None , "a" , None , "b" , "c" , None ], dtype = dtype )
345
+ result = arr .sum (skipna = skipna )
346
+ if skipna :
347
+ assert result == "abc"
348
+ else :
349
+ assert pd .isna (result )
350
+
351
+
343
352
@pytest .mark .parametrize ("method" , ["min" , "max" ])
344
353
@pytest .mark .parametrize ("skipna" , [True , False ])
345
354
def test_min_max (method , skipna , dtype , request ):
@@ -374,17 +383,6 @@ def test_min_max_numpy(method, box, dtype, request):
374
383
assert result == expected
375
384
376
385
377
- @pytest .mark .parametrize ("skipna" , [True , False ])
378
- @pytest .mark .xfail (reason = "Not implemented StringArray.sum" )
379
- def test_reduce_missing (skipna , dtype ):
380
- arr = pd .Series ([None , "a" , None , "b" , "c" , None ], dtype = dtype )
381
- result = arr .sum (skipna = skipna )
382
- if skipna :
383
- assert result == "abc"
384
- else :
385
- assert pd .isna (result )
386
-
387
-
388
386
def test_fillna_args (dtype , request ):
389
387
# GH 37987
390
388
0 commit comments