Skip to content

Commit b5707d6

Browse files
authored
TST: strictly xfail (#38901)
1 parent 167dd0d commit b5707d6

File tree

14 files changed

+247
-108
lines changed

14 files changed

+247
-108
lines changed

pandas/tests/extension/test_categorical.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,9 @@ class TestConstructors(base.BaseConstructorsTests):
117117

118118

119119
class TestReshaping(base.BaseReshapingTests):
120+
@pytest.mark.xfail(reason="Deliberately upcast to object?")
120121
def test_concat_with_reindex(self, data):
121-
pytest.xfail(reason="Deliberately upcast to object?")
122+
super().test_concat_with_reindex(data)
122123

123124

124125
class TestGetitem(base.BaseGetitemTests):

pandas/tests/frame/test_reductions.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -1229,13 +1229,15 @@ def test_min_max_dt64_with_NaT(self):
12291229
exp = Series([pd.NaT], index=["foo"])
12301230
tm.assert_series_equal(res, exp)
12311231

1232-
def test_min_max_dt64_with_NaT_skipna_false(self, tz_naive_fixture):
1232+
def test_min_max_dt64_with_NaT_skipna_false(self, request, tz_naive_fixture):
12331233
# GH#36907
12341234
tz = tz_naive_fixture
12351235
if isinstance(tz, tzlocal) and is_platform_windows():
1236-
pytest.xfail(
1237-
reason="GH#37659 OSError raised within tzlocal bc Windows "
1238-
"chokes in times before 1970-01-01"
1236+
request.node.add_marker(
1237+
pytest.mark.xfail(
1238+
reason="GH#37659 OSError raised within tzlocal bc Windows "
1239+
"chokes in times before 1970-01-01"
1240+
)
12391241
)
12401242

12411243
df = DataFrame(

pandas/tests/frame/test_ufunc.py

+18-6
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ def test_unary_unary(dtype):
2424

2525

2626
@pytest.mark.parametrize("dtype", dtypes)
27-
def test_unary_binary(dtype):
27+
def test_unary_binary(request, dtype):
2828
# unary input, binary output
2929
if pd.api.types.is_extension_array_dtype(dtype) or isinstance(dtype, dict):
30-
pytest.xfail(reason="Extension / mixed with multiple outuputs not implemented.")
30+
request.node.add_marker(
31+
pytest.mark.xfail(
32+
reason="Extension / mixed with multiple outputs not implemented."
33+
)
34+
)
3135

3236
values = np.array([[-1, -1], [1, 1]], dtype="int64")
3337
df = pd.DataFrame(values, columns=["A", "B"], index=["a", "b"]).astype(dtype=dtype)
@@ -55,14 +59,18 @@ def test_binary_input_dispatch_binop(dtype):
5559

5660
@pytest.mark.parametrize("dtype_a", dtypes)
5761
@pytest.mark.parametrize("dtype_b", dtypes)
58-
def test_binary_input_aligns_columns(dtype_a, dtype_b):
62+
def test_binary_input_aligns_columns(request, dtype_a, dtype_b):
5963
if (
6064
pd.api.types.is_extension_array_dtype(dtype_a)
6165
or isinstance(dtype_a, dict)
6266
or pd.api.types.is_extension_array_dtype(dtype_b)
6367
or isinstance(dtype_b, dict)
6468
):
65-
pytest.xfail(reason="Extension / mixed with multiple inputs not implemented.")
69+
request.node.add_marker(
70+
pytest.mark.xfail(
71+
reason="Extension / mixed with multiple inputs not implemented."
72+
)
73+
)
6674

6775
df1 = pd.DataFrame({"A": [1, 2], "B": [3, 4]}).astype(dtype_a)
6876

@@ -80,9 +88,13 @@ def test_binary_input_aligns_columns(dtype_a, dtype_b):
8088

8189

8290
@pytest.mark.parametrize("dtype", dtypes)
83-
def test_binary_input_aligns_index(dtype):
91+
def test_binary_input_aligns_index(request, dtype):
8492
if pd.api.types.is_extension_array_dtype(dtype) or isinstance(dtype, dict):
85-
pytest.xfail(reason="Extension / mixed with multiple inputs not implemented.")
93+
request.node.add_marker(
94+
pytest.mark.xfail(
95+
reason="Extension / mixed with multiple inputs not implemented."
96+
)
97+
)
8698
df1 = pd.DataFrame({"A": [1, 2], "B": [3, 4]}, index=["a", "b"]).astype(dtype)
8799
df2 = pd.DataFrame({"A": [1, 2], "B": [3, 4]}, index=["a", "c"]).astype(dtype)
88100
result = np.heaviside(df1, df2)

pandas/tests/generic/test_finalize.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -547,14 +547,14 @@ def test_finalize_called_eval_numexpr():
547547
(pd.DataFrame({"A": [1]}), pd.Series([1])),
548548
],
549549
)
550-
def test_binops(args, annotate, all_arithmetic_functions):
550+
def test_binops(request, args, annotate, all_arithmetic_functions):
551551
# This generates 326 tests... Is that needed?
552552
left, right = args
553553
if annotate == "both" and isinstance(left, int) or isinstance(right, int):
554554
return
555555

556556
if isinstance(left, pd.DataFrame) or isinstance(right, pd.DataFrame):
557-
pytest.xfail(reason="not implemented")
557+
request.node.add_marker(pytest.mark.xfail(reason="not implemented"))
558558

559559
if annotate in {"left", "both"} and not isinstance(left, int):
560560
left.attrs = {"a": 1}

pandas/tests/groupby/transform/test_transform.py

+15-9
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@ def test_transform_broadcast(tsframe, ts):
158158
assert_fp_equal(res.xs(idx), agged[idx])
159159

160160

161-
def test_transform_axis_1(transformation_func):
161+
def test_transform_axis_1(request, transformation_func):
162162
# GH 36308
163163
if transformation_func == "tshift":
164-
pytest.xfail("tshift is deprecated")
164+
request.node.add_marker(pytest.mark.xfail(reason="tshift is deprecated"))
165165
args = ("ffill",) if transformation_func == "fillna" else ()
166166

167167
df = DataFrame({"a": [1, 2], "b": [3, 4], "c": [5, 6]}, index=["x", "y"])
@@ -333,7 +333,7 @@ def test_dispatch_transform(tsframe):
333333
tm.assert_frame_equal(filled, expected)
334334

335335

336-
def test_transform_transformation_func(transformation_func):
336+
def test_transform_transformation_func(request, transformation_func):
337337
# GH 30918
338338
df = DataFrame(
339339
{
@@ -354,7 +354,7 @@ def test_transform_transformation_func(transformation_func):
354354
"Current behavior of groupby.tshift is inconsistent with other "
355355
"transformations. See GH34452 for more details"
356356
)
357-
pytest.xfail(msg)
357+
request.node.add_marker(pytest.mark.xfail(reason=msg))
358358
else:
359359
test_op = lambda x: x.transform(transformation_func)
360360
mock_op = lambda x: getattr(x, transformation_func)()
@@ -1038,16 +1038,22 @@ def test_transform_invalid_name_raises():
10381038
Series([0, 0, 0, 1, 1, 1], index=["A", "B", "C", "D", "E", "F"]),
10391039
],
10401040
)
1041-
def test_transform_agg_by_name(reduction_func, obj):
1041+
def test_transform_agg_by_name(request, reduction_func, obj):
10421042
func = reduction_func
10431043
g = obj.groupby(np.repeat([0, 1], 3))
10441044

10451045
if func == "ngroup": # GH#27468
1046-
pytest.xfail("TODO: g.transform('ngroup') doesn't work")
1047-
if func == "size": # GH#27469
1048-
pytest.xfail("TODO: g.transform('size') doesn't work")
1046+
request.node.add_marker(
1047+
pytest.mark.xfail(reason="TODO: g.transform('ngroup') doesn't work")
1048+
)
1049+
if func == "size" and obj.ndim == 2: # GH#27469
1050+
request.node.add_marker(
1051+
pytest.mark.xfail(reason="TODO: g.transform('size') doesn't work")
1052+
)
10491053
if func == "corrwith" and isinstance(obj, Series): # GH#32293
1050-
pytest.xfail("TODO: implement SeriesGroupBy.corrwith")
1054+
request.node.add_marker(
1055+
pytest.mark.xfail(reason="TODO: implement SeriesGroupBy.corrwith")
1056+
)
10511057

10521058
args = {"nth": [0], "quantile": [0.5], "corrwith": [obj]}.get(func, [])
10531059

pandas/tests/indexes/datetimes/test_ops.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,12 @@ def test_repeat(self, tz_naive_fixture):
123123
("U", "microsecond"),
124124
],
125125
)
126-
def test_resolution(self, tz_naive_fixture, freq, expected):
126+
def test_resolution(self, request, tz_naive_fixture, freq, expected):
127127
tz = tz_naive_fixture
128128
if freq == "A" and not IS64 and isinstance(tz, tzlocal):
129-
pytest.xfail(reason="OverflowError inside tzlocal past 2038")
129+
request.node.add_marker(
130+
pytest.mark.xfail(reason="OverflowError inside tzlocal past 2038")
131+
)
130132

131133
idx = date_range(start="2013-04-01", periods=30, freq=freq, tz=tz)
132134
assert idx.resolution == expected

pandas/tests/indexes/test_base.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1596,13 +1596,15 @@ def test_isin_nan_common_object(self, nulls_fixture, nulls_fixture2):
15961596
np.array([False, False]),
15971597
)
15981598

1599-
def test_isin_nan_common_float64(self, nulls_fixture):
1599+
def test_isin_nan_common_float64(self, request, nulls_fixture):
16001600
if nulls_fixture is pd.NaT:
16011601
pytest.skip("pd.NaT not compatible with Float64Index")
16021602

16031603
# Float64Index overrides isin, so must be checked separately
16041604
if nulls_fixture is pd.NA:
1605-
pytest.xfail("Float64Index cannot contain pd.NA")
1605+
request.node.add_marker(
1606+
pytest.mark.xfail(reason="Float64Index cannot contain pd.NA")
1607+
)
16061608

16071609
tm.assert_numpy_array_equal(
16081610
Float64Index([1.0, nulls_fixture]).isin([np.nan]), np.array([False, True])

pandas/tests/indexes/test_setops.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,21 @@ def test_union_same_types(index):
3838
assert idx1.union(idx2).dtype == idx1.dtype
3939

4040

41-
def test_union_different_types(index, index_fixture2):
41+
def test_union_different_types(request, index, index_fixture2):
4242
# This test only considers combinations of indices
4343
# GH 23525
4444
idx1, idx2 = index, index_fixture2
4545
type_pair = tuple(sorted([type(idx1), type(idx2)], key=lambda x: str(x)))
4646
if type_pair in COMPATIBLE_INCONSISTENT_PAIRS:
47-
pytest.xfail("This test only considers non compatible indexes.")
47+
request.node.add_marker(
48+
pytest.mark.xfail(reason="This test only considers non compatible indexes.")
49+
)
4850

4951
if any(isinstance(idx, pd.MultiIndex) for idx in (idx1, idx2)):
5052
pytest.xfail("This test doesn't consider multiindixes.")
5153

5254
if is_dtype_equal(idx1.dtype, idx2.dtype):
53-
pytest.xfail("This test only considers non matching dtypes.")
55+
pytest.skip("This test only considers non matching dtypes.")
5456

5557
# A union with a CategoricalIndex (even as dtype('O')) and a
5658
# non-CategoricalIndex can only be made if both indices are monotonic.

pandas/tests/indexing/test_coercion.py

+46-23
Original file line numberDiff line numberDiff line change
@@ -339,26 +339,33 @@ def test_setitem_index_float64(self, val, exp_dtype, request):
339339
exp_index = pd.Index([1.1, 2.1, 3.1, 4.1, val])
340340
self._assert_setitem_index_conversion(obj, val, exp_index, exp_dtype)
341341

342+
@pytest.mark.xfail(reason="Test not implemented")
342343
def test_setitem_series_period(self):
343-
pytest.xfail("Test not implemented")
344+
raise NotImplementedError
344345

346+
@pytest.mark.xfail(reason="Test not implemented")
345347
def test_setitem_index_complex128(self):
346-
pytest.xfail("Test not implemented")
348+
raise NotImplementedError
347349

350+
@pytest.mark.xfail(reason="Test not implemented")
348351
def test_setitem_index_bool(self):
349-
pytest.xfail("Test not implemented")
352+
raise NotImplementedError
350353

354+
@pytest.mark.xfail(reason="Test not implemented")
351355
def test_setitem_index_datetime64(self):
352-
pytest.xfail("Test not implemented")
356+
raise NotImplementedError
353357

358+
@pytest.mark.xfail(reason="Test not implemented")
354359
def test_setitem_index_datetime64tz(self):
355-
pytest.xfail("Test not implemented")
360+
raise NotImplementedError
356361

362+
@pytest.mark.xfail(reason="Test not implemented")
357363
def test_setitem_index_timedelta64(self):
358-
pytest.xfail("Test not implemented")
364+
raise NotImplementedError
359365

366+
@pytest.mark.xfail(reason="Test not implemented")
360367
def test_setitem_index_period(self):
361-
pytest.xfail("Test not implemented")
368+
raise NotImplementedError
362369

363370

364371
class TestInsertIndexCoercion(CoercionBase):
@@ -511,11 +518,13 @@ def test_insert_index_period(self, insert, coerced_val, coerced_dtype):
511518
# passing keywords to pd.Index
512519
pd.Index(data, freq="M")
513520

521+
@pytest.mark.xfail(reason="Test not implemented")
514522
def test_insert_index_complex128(self):
515-
pytest.xfail("Test not implemented")
523+
raise NotImplementedError
516524

525+
@pytest.mark.xfail(reason="Test not implemented")
517526
def test_insert_index_bool(self):
518-
pytest.xfail("Test not implemented")
527+
raise NotImplementedError
519528

520529

521530
class TestWhereCoercion(CoercionBase):
@@ -760,17 +769,21 @@ def test_where_index_datetime64tz(self):
760769

761770
self._assert_where_conversion(obj, cond, values, exp, exp_dtype)
762771

772+
@pytest.mark.xfail(reason="Test not implemented")
763773
def test_where_index_complex128(self):
764-
pytest.xfail("Test not implemented")
774+
raise NotImplementedError
765775

776+
@pytest.mark.xfail(reason="Test not implemented")
766777
def test_where_index_bool(self):
767-
pytest.xfail("Test not implemented")
778+
raise NotImplementedError
768779

780+
@pytest.mark.xfail(reason="Test not implemented")
769781
def test_where_series_timedelta64(self):
770-
pytest.xfail("Test not implemented")
782+
raise NotImplementedError
771783

784+
@pytest.mark.xfail(reason="Test not implemented")
772785
def test_where_series_period(self):
773-
pytest.xfail("Test not implemented")
786+
raise NotImplementedError
774787

775788
@pytest.mark.parametrize(
776789
"value", [pd.Timedelta(days=9), timedelta(days=9), np.timedelta64(9, "D")]
@@ -822,8 +835,9 @@ class TestFillnaSeriesCoercion(CoercionBase):
822835

823836
method = "fillna"
824837

838+
@pytest.mark.xfail(reason="Test not implemented")
825839
def test_has_comprehensive_tests(self):
826-
pytest.xfail("Test not implemented")
840+
raise NotImplementedError
827841

828842
def _assert_fillna_conversion(self, original, value, expected, expected_dtype):
829843
""" test coercion triggered by fillna """
@@ -942,29 +956,37 @@ def test_fillna_datetime64tz(self, index_or_series, fill_val, fill_dtype):
942956
)
943957
self._assert_fillna_conversion(obj, fill_val, exp, fill_dtype)
944958

959+
@pytest.mark.xfail(reason="Test not implemented")
945960
def test_fillna_series_int64(self):
946-
pytest.xfail("Test not implemented")
961+
raise NotImplementedError
947962

963+
@pytest.mark.xfail(reason="Test not implemented")
948964
def test_fillna_index_int64(self):
949-
pytest.xfail("Test not implemented")
965+
raise NotImplementedError
950966

967+
@pytest.mark.xfail(reason="Test not implemented")
951968
def test_fillna_series_bool(self):
952-
pytest.xfail("Test not implemented")
969+
raise NotImplementedError
953970

971+
@pytest.mark.xfail(reason="Test not implemented")
954972
def test_fillna_index_bool(self):
955-
pytest.xfail("Test not implemented")
973+
raise NotImplementedError
956974

975+
@pytest.mark.xfail(reason="Test not implemented")
957976
def test_fillna_series_timedelta64(self):
958-
pytest.xfail("Test not implemented")
977+
raise NotImplementedError
959978

979+
@pytest.mark.xfail(reason="Test not implemented")
960980
def test_fillna_series_period(self):
961-
pytest.xfail("Test not implemented")
981+
raise NotImplementedError
962982

983+
@pytest.mark.xfail(reason="Test not implemented")
963984
def test_fillna_index_timedelta64(self):
964-
pytest.xfail("Test not implemented")
985+
raise NotImplementedError
965986

987+
@pytest.mark.xfail(reason="Test not implemented")
966988
def test_fillna_index_period(self):
967-
pytest.xfail("Test not implemented")
989+
raise NotImplementedError
968990

969991

970992
class TestReplaceSeriesCoercion(CoercionBase):
@@ -1120,5 +1142,6 @@ def test_replace_series_datetime_datetime(self, how, to_key, from_key):
11201142

11211143
tm.assert_series_equal(result, exp)
11221144

1145+
@pytest.mark.xfail(reason="Test not implemented")
11231146
def test_replace_series_period(self):
1124-
pytest.xfail("Test not implemented")
1147+
raise NotImplementedError

0 commit comments

Comments
 (0)