From e0d6051f985994e594b07a2b93b9ca2eff43eae4 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Sun, 15 Oct 2023 09:00:34 -1000 Subject: [PATCH] TST: Replace node.add_marker with applymarker (#55513) --- .../development/contributing_codebase.rst | 2 +- pandas/tests/apply/test_frame_apply.py | 2 +- pandas/tests/apply/test_frame_transform.py | 4 +- pandas/tests/apply/test_series_apply.py | 2 +- pandas/tests/apply/test_str.py | 6 +- pandas/tests/arithmetic/test_datetime64.py | 2 +- pandas/tests/arrays/string_/test_string.py | 6 +- pandas/tests/base/test_conversion.py | 2 +- pandas/tests/base/test_misc.py | 4 +- pandas/tests/computation/test_eval.py | 6 +- .../copy_view/test_core_functionalities.py | 2 +- .../tests/extension/decimal/test_decimal.py | 4 +- pandas/tests/extension/json/test_json.py | 6 +- pandas/tests/extension/test_arrow.py | 62 +++++++++---------- pandas/tests/extension/test_categorical.py | 4 +- pandas/tests/extension/test_masked.py | 2 +- pandas/tests/extension/test_numpy.py | 8 +-- pandas/tests/extension/test_sparse.py | 4 +- .../tests/frame/methods/test_interpolate.py | 2 +- pandas/tests/frame/methods/test_nlargest.py | 2 +- pandas/tests/frame/methods/test_quantile.py | 48 ++++---------- .../tests/frame/methods/test_sort_values.py | 4 +- .../frame/methods/test_to_dict_of_blocks.py | 2 +- pandas/tests/frame/test_arithmetic.py | 2 +- pandas/tests/frame/test_constructors.py | 4 +- pandas/tests/frame/test_reductions.py | 6 +- pandas/tests/frame/test_ufunc.py | 6 +- pandas/tests/generic/test_duplicate_labels.py | 2 +- pandas/tests/generic/test_finalize.py | 12 ++-- pandas/tests/groupby/methods/test_quantile.py | 2 +- .../groupby/methods/test_value_counts.py | 14 ++--- pandas/tests/groupby/test_categorical.py | 8 +-- pandas/tests/groupby/test_function.py | 4 +- pandas/tests/groupby/test_groupby_dropna.py | 2 +- .../tests/groupby/transform/test_transform.py | 4 +- pandas/tests/indexes/datetimes/test_ops.py | 2 +- pandas/tests/indexes/test_common.py | 4 +- pandas/tests/indexes/test_index_new.py | 2 +- pandas/tests/indexes/test_setops.py | 4 +- pandas/tests/indexing/test_loc.py | 2 +- pandas/tests/io/excel/test_readers.py | 54 ++++++++-------- pandas/tests/io/excel/test_writers.py | 2 +- pandas/tests/io/json/test_pandas.py | 4 +- pandas/tests/io/json/test_readlines.py | 16 ++--- pandas/tests/io/parser/common/test_float.py | 2 +- .../io/parser/common/test_read_errors.py | 4 +- pandas/tests/io/parser/conftest.py | 2 +- .../io/parser/dtypes/test_dtypes_basic.py | 2 +- pandas/tests/io/parser/test_comment.py | 4 +- pandas/tests/io/parser/test_compression.py | 2 +- pandas/tests/io/parser/test_encoding.py | 4 +- pandas/tests/io/parser/test_index_col.py | 2 +- pandas/tests/io/parser/test_parse_dates.py | 6 +- pandas/tests/io/parser/test_skiprows.py | 2 +- pandas/tests/io/parser/test_unsupported.py | 2 +- pandas/tests/io/pytables/test_round_trip.py | 2 +- pandas/tests/io/test_parquet.py | 6 +- pandas/tests/io/test_sql.py | 34 +++++----- .../reshape/concat/test_append_common.py | 4 +- .../scalar/timestamp/test_constructors.py | 2 +- pandas/tests/series/methods/test_astype.py | 4 +- .../tests/series/methods/test_interpolate.py | 2 +- pandas/tests/series/methods/test_map.py | 2 +- pandas/tests/series/test_arithmetic.py | 2 +- pandas/tests/series/test_constructors.py | 4 +- pandas/tests/series/test_ufunc.py | 2 +- pandas/tests/strings/test_api.py | 2 +- pandas/tests/tools/test_to_datetime.py | 2 +- pandas/tests/tools/test_to_numeric.py | 2 +- pandas/tests/tseries/offsets/test_common.py | 4 +- pandas/tests/tseries/offsets/test_offsets.py | 4 +- .../test_moments_consistency_expanding.py | 2 +- .../test_moments_consistency_rolling.py | 2 +- pandas/util/_test_decorators.py | 2 +- 74 files changed, 216 insertions(+), 242 deletions(-) diff --git a/doc/source/development/contributing_codebase.rst b/doc/source/development/contributing_codebase.rst index e0aa8be066914..e22b57dbbff17 100644 --- a/doc/source/development/contributing_codebase.rst +++ b/doc/source/development/contributing_codebase.rst @@ -540,7 +540,7 @@ xfail during the testing phase. To do so, use the ``request`` fixture: def test_xfail(request): mark = pytest.mark.xfail(raises=TypeError, reason="Indicate why here") - request.node.add_marker(mark) + request.applymarker(mark) xfail is not to be used for tests involving failure due to invalid user arguments. For these tests, we need to verify the correct exception type and error message diff --git a/pandas/tests/apply/test_frame_apply.py b/pandas/tests/apply/test_frame_apply.py index be988594ebf58..232cfceb3b6d6 100644 --- a/pandas/tests/apply/test_frame_apply.py +++ b/pandas/tests/apply/test_frame_apply.py @@ -325,7 +325,7 @@ def test_apply_empty_infer_type(ax, func, raw, axis, engine, request): mark = pytest.mark.xfail( reason="numba engine only supports raw=True at the moment" ) - request.node.add_marker(mark) + request.applymarker(mark) result = df.apply(func, axis=axis, engine=engine, raw=raw) if is_reduction: diff --git a/pandas/tests/apply/test_frame_transform.py b/pandas/tests/apply/test_frame_transform.py index 2d57515882aed..558d76ae8fdc4 100644 --- a/pandas/tests/apply/test_frame_transform.py +++ b/pandas/tests/apply/test_frame_transform.py @@ -156,7 +156,7 @@ def func(x): def test_transform_bad_dtype(op, frame_or_series, request): # GH 35964 if op == "ngroup": - request.node.add_marker( + request.applymarker( pytest.mark.xfail(raises=ValueError, reason="ngroup not valid for NDFrame") ) @@ -185,7 +185,7 @@ def test_transform_failure_typeerror(request, op): # GH 35964 if op == "ngroup": - request.node.add_marker( + request.applymarker( pytest.mark.xfail(raises=ValueError, reason="ngroup not valid for NDFrame") ) diff --git a/pandas/tests/apply/test_series_apply.py b/pandas/tests/apply/test_series_apply.py index 643b9220999f7..b8026d771baed 100644 --- a/pandas/tests/apply/test_series_apply.py +++ b/pandas/tests/apply/test_series_apply.py @@ -321,7 +321,7 @@ def test_transform(string_series, by_row): def test_transform_partial_failure(op, request): # GH 35964 if op in ("ffill", "bfill", "pad", "backfill", "shift"): - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason=f"{op} is successful on any dtype") ) diff --git a/pandas/tests/apply/test_str.py b/pandas/tests/apply/test_str.py index 363d0285cabbc..c046c60e174b3 100644 --- a/pandas/tests/apply/test_str.py +++ b/pandas/tests/apply/test_str.py @@ -31,7 +31,7 @@ @pytest.mark.parametrize("how", ["agg", "apply"]) def test_apply_with_string_funcs(request, float_frame, func, args, kwds, how): if len(args) > 1 and how == "agg": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( raises=TypeError, reason="agg/apply signature mismatch - agg passes 2nd " @@ -256,7 +256,7 @@ def test_agg_cython_table_transform_frame(df, func, expected, axis): def test_transform_groupby_kernel_series(request, string_series, op): # GH 35964 if op == "ngroup": - request.node.add_marker( + request.applymarker( pytest.mark.xfail(raises=ValueError, reason="ngroup not valid for NDFrame") ) args = [0.0] if op == "fillna" else [] @@ -269,7 +269,7 @@ def test_transform_groupby_kernel_series(request, string_series, op): @pytest.mark.parametrize("op", frame_transform_kernels) def test_transform_groupby_kernel_frame(request, axis, float_frame, op): if op == "ngroup": - request.node.add_marker( + request.applymarker( pytest.mark.xfail(raises=ValueError, reason="ngroup not valid for NDFrame") ) diff --git a/pandas/tests/arithmetic/test_datetime64.py b/pandas/tests/arithmetic/test_datetime64.py index 693b8d9483407..67bcafd583086 100644 --- a/pandas/tests/arithmetic/test_datetime64.py +++ b/pandas/tests/arithmetic/test_datetime64.py @@ -1084,7 +1084,7 @@ def test_dt64arr_addsub_intlike( # GH#19959, GH#19123, GH#19012 tz = tz_naive_fixture if box_with_array is pd.DataFrame: - request.node.add_marker( + request.applymarker( pytest.mark.xfail(raises=ValueError, reason="Axis alignment fails") ) diff --git a/pandas/tests/arrays/string_/test_string.py b/pandas/tests/arrays/string_/test_string.py index 89cc31ec5ecc8..451136225a612 100644 --- a/pandas/tests/arrays/string_/test_string.py +++ b/pandas/tests/arrays/string_/test_string.py @@ -151,7 +151,7 @@ def test_add_2d(dtype, request, arrow_string_storage): if dtype.storage in arrow_string_storage: reason = "Failed: DID NOT RAISE " mark = pytest.mark.xfail(raises=None, reason=reason) - request.node.add_marker(mark) + request.applymarker(mark) a = pd.array(["a", "b", "c"], dtype=dtype) b = np.array([["a", "b", "c"]], dtype=object) @@ -180,7 +180,7 @@ def test_mul(dtype, request, arrow_string_storage): if dtype.storage in arrow_string_storage: reason = "unsupported operand type(s) for *: 'ArrowStringArray' and 'int'" mark = pytest.mark.xfail(raises=NotImplementedError, reason=reason) - request.node.add_marker(mark) + request.applymarker(mark) a = pd.array(["a", "b", None], dtype=dtype) result = a * 2 @@ -446,7 +446,7 @@ def test_min_max_numpy(method, box, dtype, request, arrow_string_storage): else: reason = "'ArrowStringArray' object has no attribute 'max'" mark = pytest.mark.xfail(raises=TypeError, reason=reason) - request.node.add_marker(mark) + request.applymarker(mark) arr = box(["a", "b", "c", None], dtype=dtype) result = getattr(np, method)(arr) diff --git a/pandas/tests/base/test_conversion.py b/pandas/tests/base/test_conversion.py index 3e0b0dbeb5624..c0f65c23c6d35 100644 --- a/pandas/tests/base/test_conversion.py +++ b/pandas/tests/base/test_conversion.py @@ -337,7 +337,7 @@ def test_to_numpy(arr, expected, index_or_series_or_array, request): if arr.dtype.name == "int64" and box is pd.array: mark = pytest.mark.xfail(reason="thing is Int64 and to_numpy() returns object") - request.node.add_marker(mark) + request.applymarker(mark) result = thing.to_numpy() tm.assert_numpy_array_equal(result, expected) diff --git a/pandas/tests/base/test_misc.py b/pandas/tests/base/test_misc.py index 3ca53c4010449..c6fd4955d2d63 100644 --- a/pandas/tests/base/test_misc.py +++ b/pandas/tests/base/test_misc.py @@ -141,7 +141,7 @@ def test_searchsorted(request, index_or_series_obj): if isinstance(obj, pd.MultiIndex): # See gh-14833 - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="np.searchsorted doesn't work on pd.MultiIndex: GH 14833" ) @@ -150,7 +150,7 @@ def test_searchsorted(request, index_or_series_obj): # TODO: Should Series cases also raise? Looks like they use numpy # comparison semantics https://github.com/numpy/numpy/issues/15981 mark = pytest.mark.xfail(reason="complex objects are not comparable") - request.node.add_marker(mark) + request.applymarker(mark) max_obj = max(obj, default=0) index = np.searchsorted(obj, max_obj) diff --git a/pandas/tests/computation/test_eval.py b/pandas/tests/computation/test_eval.py index 9c630e29ea8e6..f336ef34cae0a 100644 --- a/pandas/tests/computation/test_eval.py +++ b/pandas/tests/computation/test_eval.py @@ -194,7 +194,7 @@ def test_compound_invert_op(self, op, lhs, rhs, request, engine, parser): reason="Looks like expected is negative, unclear whether " "expected is incorrect or result is incorrect" ) - request.node.add_marker(mark) + request.applymarker(mark) skip_these = ["in", "not in"] ex = f"~(lhs {op} rhs)" @@ -860,7 +860,7 @@ def test_basic_series_frame_alignment( f"parser={parser}, index_name={index_name}, " f"r_idx_type={r_idx_type}, c_idx_type={c_idx_type}" ) - request.node.add_marker(pytest.mark.xfail(reason=reason, strict=False)) + request.applymarker(pytest.mark.xfail(reason=reason, strict=False)) df = tm.makeCustomDataframe( 10, 7, data_gen_f=f, r_idx_type=r_idx_type, c_idx_type=c_idx_type ) @@ -1883,7 +1883,7 @@ def test_negate_lt_eq_le(engine, parser): def test_eval_no_support_column_name(request, column): # GH 44603 if column in ["True", "False", "inf", "Inf"]: - request.node.add_marker( + request.applymarker( pytest.mark.xfail( raises=KeyError, reason=f"GH 47859 DataFrame eval not supported with {column}", diff --git a/pandas/tests/copy_view/test_core_functionalities.py b/pandas/tests/copy_view/test_core_functionalities.py index 5c177465d2fa4..bfdf2b92fd326 100644 --- a/pandas/tests/copy_view/test_core_functionalities.py +++ b/pandas/tests/copy_view/test_core_functionalities.py @@ -57,7 +57,7 @@ def test_setitem_with_view_invalidated_does_not_copy(using_copy_on_write, reques mark = pytest.mark.xfail( reason="blk.delete does not track references correctly" ) - request.node.add_marker(mark) + request.applymarker(mark) assert np.shares_memory(arr, get_array(df, "a")) diff --git a/pandas/tests/extension/decimal/test_decimal.py b/pandas/tests/extension/decimal/test_decimal.py index 8dbd1c4c511d0..5ccffd1d25b3d 100644 --- a/pandas/tests/extension/decimal/test_decimal.py +++ b/pandas/tests/extension/decimal/test_decimal.py @@ -85,14 +85,14 @@ def check_reduce(self, ser: pd.Series, op_name: str, skipna: bool): def test_reduce_series_numeric(self, data, all_numeric_reductions, skipna, request): if all_numeric_reductions in ["kurt", "skew", "sem", "median"]: mark = pytest.mark.xfail(raises=NotImplementedError) - request.node.add_marker(mark) + request.applymarker(mark) super().test_reduce_series_numeric(data, all_numeric_reductions, skipna) def test_reduce_frame(self, data, all_numeric_reductions, skipna, request): op_name = all_numeric_reductions if op_name in ["skew", "median"]: mark = pytest.mark.xfail(raises=NotImplementedError) - request.node.add_marker(mark) + request.applymarker(mark) return super().test_reduce_frame(data, all_numeric_reductions, skipna) diff --git a/pandas/tests/extension/json/test_json.py b/pandas/tests/extension/json/test_json.py index 68a27a28b160f..71133030a5c18 100644 --- a/pandas/tests/extension/json/test_json.py +++ b/pandas/tests/extension/json/test_json.py @@ -237,7 +237,7 @@ def test_equals_same_data_different_object( ): if using_copy_on_write: mark = pytest.mark.xfail(reason="Fails with CoW") - request.node.add_marker(mark) + request.applymarker(mark) super().test_equals_same_data_different_object(data) @@ -300,7 +300,7 @@ class TestArithmeticOps(BaseJSON, base.BaseArithmeticOpsTests): def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request): if len(data[0]) != 1: mark = pytest.mark.xfail(reason="raises in coercing to Series") - request.node.add_marker(mark) + request.applymarker(mark) super().test_arith_frame_with_scalar(data, all_arithmetic_operators) @@ -308,7 +308,7 @@ class TestComparisonOps(BaseJSON, base.BaseComparisonOpsTests): def test_compare_array(self, data, comparison_op, request): if comparison_op.__name__ in ["eq", "ne"]: mark = pytest.mark.xfail(reason="Comparison methods not implemented") - request.node.add_marker(mark) + request.applymarker(mark) super().test_compare_array(data, comparison_op) diff --git a/pandas/tests/extension/test_arrow.py b/pandas/tests/extension/test_arrow.py index 41312f45838a9..86aef2642750e 100644 --- a/pandas/tests/extension/test_arrow.py +++ b/pandas/tests/extension/test_arrow.py @@ -78,7 +78,7 @@ def _require_timezone_database(request): "on CI to path to the tzdata for pyarrow." ), ) - request.node.add_marker(mark) + request.applymarker(mark) @pytest.fixture(params=tm.ALL_PYARROW_DTYPES, ids=str) @@ -271,7 +271,7 @@ class TestArrowArray(base.ExtensionTests): def test_astype_str(self, data, request): pa_dtype = data.dtype.pyarrow_dtype if pa.types.is_binary(pa_dtype): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=f"For {pa_dtype} .astype(str) decodes.", ) @@ -286,7 +286,7 @@ def test_from_dtype(self, data, request): else: reason = f"pyarrow.type_for_alias cannot infer {pa_dtype}" - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=reason, ) @@ -313,7 +313,7 @@ def test_from_sequence_pa_array_notimplemented(self, request): def test_from_sequence_of_strings_pa_array(self, data, request): pa_dtype = data.dtype.pyarrow_dtype if pa.types.is_time64(pa_dtype) and pa_dtype.equals("time64[ns]") and not PY311: - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Nanosecond time parsing not supported.", ) @@ -321,7 +321,7 @@ def test_from_sequence_of_strings_pa_array(self, data, request): elif pa_version_under11p0 and ( pa.types.is_duration(pa_dtype) or pa.types.is_decimal(pa_dtype) ): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( raises=pa.ArrowNotImplementedError, reason=f"pyarrow doesn't support parsing {pa_dtype}", @@ -402,12 +402,12 @@ def test_accumulate_series(self, data, all_numeric_accumulations, skipna, reques mark = pytest.mark.xfail( reason=f"{all_numeric_accumulations} not implemented for pyarrow < 9" ) - request.node.add_marker(mark) + request.applymarker(mark) elif all_numeric_accumulations == "cumsum" and ( pa.types.is_boolean(pa_type) or pa.types.is_decimal(pa_type) ): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=f"{all_numeric_accumulations} not implemented for {pa_type}", raises=NotImplementedError, @@ -496,19 +496,19 @@ def test_reduce_series_numeric(self, data, all_numeric_reductions, skipna, reque if all_numeric_reductions in {"skew", "kurt"} and ( dtype._is_numeric or dtype.kind == "b" ): - request.node.add_marker(xfail_mark) + request.applymarker(xfail_mark) elif ( all_numeric_reductions in {"var", "std", "median"} and pa_version_under7p0 and pa.types.is_decimal(pa_dtype) ): - request.node.add_marker(xfail_mark) + request.applymarker(xfail_mark) elif ( all_numeric_reductions == "sem" and pa_version_under8p0 and (dtype._is_numeric or pa.types.is_temporal(pa_dtype)) ): - request.node.add_marker(xfail_mark) + request.applymarker(xfail_mark) elif pa.types.is_boolean(pa_dtype) and all_numeric_reductions in { "sem", @@ -516,7 +516,7 @@ def test_reduce_series_numeric(self, data, all_numeric_reductions, skipna, reque "var", "median", }: - request.node.add_marker(xfail_mark) + request.applymarker(xfail_mark) super().test_reduce_series_numeric(data, all_numeric_reductions, skipna) @pytest.mark.parametrize("skipna", [True, False]) @@ -532,7 +532,7 @@ def test_reduce_series_boolean(self, data, all_boolean_reductions, skipna, reque if pa.types.is_string(pa_dtype) or pa.types.is_binary(pa_dtype): # We *might* want to make this behave like the non-pyarrow cases, # but have not yet decided. - request.node.add_marker(xfail_mark) + request.applymarker(xfail_mark) return super().test_reduce_series_boolean(data, all_boolean_reductions, skipna) @@ -560,7 +560,7 @@ def test_reduce_frame(self, data, all_numeric_reductions, skipna, request): if op_name == "skew": if data.dtype._is_numeric: mark = pytest.mark.xfail(reason="skew not implemented") - request.node.add_marker(mark) + request.applymarker(mark) return super().test_reduce_frame(data, all_numeric_reductions, skipna) @pytest.mark.parametrize("typ", ["int64", "uint64", "float64"]) @@ -592,7 +592,7 @@ def test_in_numeric_groupby(self, data_for_grouping): def test_construct_from_string_own_name(self, dtype, request): pa_dtype = dtype.pyarrow_dtype if pa.types.is_decimal(pa_dtype): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( raises=NotImplementedError, reason=f"pyarrow.type_for_alias cannot infer {pa_dtype}", @@ -616,7 +616,7 @@ def test_is_dtype_from_name(self, dtype, request): assert not type(dtype).is_dtype(dtype.name) else: if pa.types.is_decimal(pa_dtype): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( raises=NotImplementedError, reason=f"pyarrow.type_for_alias cannot infer {pa_dtype}", @@ -638,7 +638,7 @@ def test_get_common_dtype(self, dtype, request): or pa.types.is_binary(pa_dtype) or pa.types.is_decimal(pa_dtype) ): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=( f"{pa_dtype} does not have associated numpy " @@ -690,21 +690,21 @@ def test_setitem_preserves_views(self, data): def test_EA_types(self, engine, data, dtype_backend, request): pa_dtype = data.dtype.pyarrow_dtype if pa.types.is_decimal(pa_dtype): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( raises=NotImplementedError, reason=f"Parameterized types {pa_dtype} not supported.", ) ) elif pa.types.is_timestamp(pa_dtype) and pa_dtype.unit in ("us", "ns"): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( raises=ValueError, reason="https://github.com/pandas-dev/pandas/issues/49767", ) ) elif pa.types.is_binary(pa_dtype): - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason="CSV parsers don't correctly handle binary") ) df = pd.DataFrame({"with_dtype": pd.Series(data, dtype=str(data.dtype))}) @@ -725,7 +725,7 @@ def test_EA_types(self, engine, data, dtype_backend, request): def test_invert(self, data, request): pa_dtype = data.dtype.pyarrow_dtype if not (pa.types.is_boolean(pa_dtype) or pa.types.is_integer(pa_dtype)): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( raises=pa.ArrowNotImplementedError, reason=f"pyarrow.compute.invert does support {pa_dtype}", @@ -737,7 +737,7 @@ def test_invert(self, data, request): def test_diff(self, data, periods, request): pa_dtype = data.dtype.pyarrow_dtype if pa.types.is_unsigned_integer(pa_dtype) and periods == 1: - request.node.add_marker( + request.applymarker( pytest.mark.xfail( raises=pa.ArrowInvalid, reason=( @@ -756,7 +756,7 @@ def test_value_counts_returns_pyarrow_int64(self, data): def test_argmin_argmax(self, data_for_sorting, data_missing_for_sorting, request): pa_dtype = data_for_sorting.dtype.pyarrow_dtype if pa.types.is_decimal(pa_dtype) and pa_version_under7p0: - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=f"No pyarrow kernel for {pa_dtype}", raises=pa.ArrowNotImplementedError, @@ -782,7 +782,7 @@ def test_argreduce_series( ): pa_dtype = data_missing_for_sorting.dtype.pyarrow_dtype if pa.types.is_decimal(pa_dtype) and pa_version_under7p0 and skipna: - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=f"No pyarrow kernel for {pa_dtype}", raises=pa.ArrowNotImplementedError, @@ -1036,7 +1036,7 @@ def test_arith_series_with_scalar(self, data, all_arithmetic_operators, request) mark = self._get_arith_xfail_marker(all_arithmetic_operators, pa_dtype) if mark is not None: - request.node.add_marker(mark) + request.applymarker(mark) super().test_arith_series_with_scalar(data, all_arithmetic_operators) @@ -1050,7 +1050,7 @@ def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request): mark = self._get_arith_xfail_marker(all_arithmetic_operators, pa_dtype) if mark is not None: - request.node.add_marker(mark) + request.applymarker(mark) super().test_arith_frame_with_scalar(data, all_arithmetic_operators) @@ -1066,7 +1066,7 @@ def test_arith_series_with_array(self, data, all_arithmetic_operators, request): and pa.types.is_unsigned_integer(pa_dtype) and not pa_version_under7p0 ): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( raises=pa.ArrowInvalid, reason=( @@ -1078,7 +1078,7 @@ def test_arith_series_with_array(self, data, all_arithmetic_operators, request): mark = self._get_arith_xfail_marker(all_arithmetic_operators, pa_dtype) if mark is not None: - request.node.add_marker(mark) + request.applymarker(mark) op_name = all_arithmetic_operators ser = pd.Series(data) @@ -1092,7 +1092,7 @@ def test_add_series_with_extension_array(self, data, request): pa_dtype = data.dtype.pyarrow_dtype if pa_dtype.equals("int8"): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( raises=pa.ArrowInvalid, reason=f"raises on overflow for {pa_dtype}", @@ -1368,7 +1368,7 @@ def test_quantile(data, interpolation, quantile, request): elif pa.types.is_temporal(data._pa_array.type): pass else: - request.node.add_marker( + request.applymarker( pytest.mark.xfail( raises=pa.ArrowNotImplementedError, reason=f"quantile not supported by pyarrow for {pa_dtype}", @@ -2830,7 +2830,7 @@ def test_infer_dtype_pyarrow_dtype(data, request): reason="in infer_dtype pd.NA is not ignored in these cases " "even with skipna=True in the list(data) check below" ) - request.node.add_marker(mark) + request.applymarker(mark) assert res == lib.infer_dtype(list(data), skipna=True) @@ -2881,7 +2881,7 @@ def test_arithmetic_temporal(pa_type, request): raises=pa.ArrowNotImplementedError, reason="Function 'subtract_checked' has no kernel matching input types", ) - request.node.add_marker(mark) + request.applymarker(mark) arr = ArrowExtensionArray(pa.array([1, 2, 3], type=pa_type)) unit = pa_type.unit diff --git a/pandas/tests/extension/test_categorical.py b/pandas/tests/extension/test_categorical.py index 82b6c54bc3106..5cde5df4bc007 100644 --- a/pandas/tests/extension/test_categorical.py +++ b/pandas/tests/extension/test_categorical.py @@ -148,7 +148,7 @@ def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request): # frame & scalar op_name = all_arithmetic_operators if op_name == "__rmod__": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="rmod never called when string is first argument" ) @@ -158,7 +158,7 @@ def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request): def test_arith_series_with_scalar(self, data, all_arithmetic_operators, request): op_name = all_arithmetic_operators if op_name == "__rmod__": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="rmod never called when string is first argument" ) diff --git a/pandas/tests/extension/test_masked.py b/pandas/tests/extension/test_masked.py index d27e9b8b9e983..bd12bcced1448 100644 --- a/pandas/tests/extension/test_masked.py +++ b/pandas/tests/extension/test_masked.py @@ -234,7 +234,7 @@ def test_divmod_series_array(self, data, data_for_twos, request): "floordiv but not for divmod. This matches what we do for " "non-masked bool dtype." ) - request.node.add_marker(mark) + request.applymarker(mark) super().test_divmod_series_array(data, data_for_twos) def test_combine_le(self, data_repeated): diff --git a/pandas/tests/extension/test_numpy.py b/pandas/tests/extension/test_numpy.py index 542e938d1a40a..04b25fd0566da 100644 --- a/pandas/tests/extension/test_numpy.py +++ b/pandas/tests/extension/test_numpy.py @@ -169,7 +169,7 @@ def skip_numpy_object(dtype, request): """ if dtype == "object": mark = pytest.mark.xfail(reason="Fails for object dtype") - request.node.add_marker(mark) + request.applymarker(mark) skip_nested = pytest.mark.usefixtures("skip_numpy_object") @@ -198,7 +198,7 @@ def test_series_constructor_scalar_with_index(self, data, dtype): class TestDtype(BaseNumPyTests, base.BaseDtypeTests): def test_check_dtype(self, data, request): if data.dtype.numpy_dtype == "object": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=f"NumpyExtensionArray expectedly clashes with a " f"NumPy name: {data.dtype.numpy_dtype}" @@ -261,7 +261,7 @@ def test_diff(self, data, periods): def test_insert(self, data, request): if data.dtype.numpy_dtype == object: mark = pytest.mark.xfail(reason="Dimension mismatch in np.concatenate") - request.node.add_marker(mark) + request.applymarker(mark) super().test_insert(data) @@ -289,7 +289,7 @@ def test_arith_series_with_array(self, data, all_arithmetic_operators, request): opname = all_arithmetic_operators if data.dtype.numpy_dtype == object and opname not in ["__add__", "__radd__"]: mark = pytest.mark.xfail(reason="Fails for object dtype") - request.node.add_marker(mark) + request.applymarker(mark) super().test_arith_series_with_array(data, all_arithmetic_operators) @skip_nested diff --git a/pandas/tests/extension/test_sparse.py b/pandas/tests/extension/test_sparse.py index f56dea3f43de7..003f50e8e23a2 100644 --- a/pandas/tests/extension/test_sparse.py +++ b/pandas/tests/extension/test_sparse.py @@ -214,7 +214,7 @@ def test_fillna_limit_backfill(self, data_missing): def test_fillna_no_op_returns_copy(self, data, request): if np.isnan(data.fill_value): - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason="returns array with different fill value") ) super().test_fillna_no_op_returns_copy(data) @@ -392,7 +392,7 @@ def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request): "rmod", ]: mark = pytest.mark.xfail(reason="result dtype.fill_value mismatch") - request.node.add_marker(mark) + request.applymarker(mark) super().test_arith_frame_with_scalar(data, all_arithmetic_operators) diff --git a/pandas/tests/frame/methods/test_interpolate.py b/pandas/tests/frame/methods/test_interpolate.py index 67aa07dd83764..bb12d7e202e09 100644 --- a/pandas/tests/frame/methods/test_interpolate.py +++ b/pandas/tests/frame/methods/test_interpolate.py @@ -54,7 +54,7 @@ def test_interpolate_inplace(self, frame_or_series, using_array_manager, request # GH#44749 if using_array_manager and frame_or_series is DataFrame: mark = pytest.mark.xfail(reason=".values-based in-place check is invalid") - request.node.add_marker(mark) + request.applymarker(mark) obj = frame_or_series([1, np.nan, 2]) orig = obj.values diff --git a/pandas/tests/frame/methods/test_nlargest.py b/pandas/tests/frame/methods/test_nlargest.py index 0bdf9a0e5c007..1196f8cd3886a 100644 --- a/pandas/tests/frame/methods/test_nlargest.py +++ b/pandas/tests/frame/methods/test_nlargest.py @@ -169,7 +169,7 @@ def test_nlargest_n_duplicate_index(self, df_duplicates, n, order, request): if Version(np.__version__) >= Version("1.25") and ( (order == ["a"] and n in (1, 2, 3, 4)) or (order == ["a", "b"]) and n == 5 ): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=( "pandas default unstable sorting of duplicates" diff --git a/pandas/tests/frame/methods/test_quantile.py b/pandas/tests/frame/methods/test_quantile.py index 61b253b24a7ec..4bfe364e5eafc 100644 --- a/pandas/tests/frame/methods/test_quantile.py +++ b/pandas/tests/frame/methods/test_quantile.py @@ -63,7 +63,7 @@ def test_quantile( tm.assert_series_equal(result, expected) else: tm.assert_index_equal(result.index, expected.index) - request.node.add_marker( + request.applymarker( pytest.mark.xfail( using_array_manager, reason="Name set incorrectly for arraymanager" ) @@ -83,7 +83,7 @@ def test_quantile( tm.assert_series_equal(result, expected) else: tm.assert_index_equal(result.index, expected.index) - request.node.add_marker( + request.applymarker( pytest.mark.xfail( using_array_manager, reason="Name set incorrectly for arraymanager" ) @@ -107,9 +107,7 @@ def test_non_numeric_exclusion(self, interp_method, request, using_array_manager if interpolation == "nearest": xp = (xp + 0.5).astype(np.int64) if method == "table" and using_array_manager: - request.node.add_marker( - pytest.mark.xfail(reason="Axis name incorrectly set.") - ) + request.applymarker(pytest.mark.xfail(reason="Axis name incorrectly set.")) tm.assert_series_equal(rs, xp) def test_axis(self, interp_method, request, using_array_manager): @@ -121,9 +119,7 @@ def test_axis(self, interp_method, request, using_array_manager): if interpolation == "nearest": expected = expected.astype(np.int64) if method == "table" and using_array_manager: - request.node.add_marker( - pytest.mark.xfail(reason="Axis name incorrectly set.") - ) + request.applymarker(pytest.mark.xfail(reason="Axis name incorrectly set.")) tm.assert_series_equal(result, expected) result = df.quantile( @@ -151,9 +147,7 @@ def test_axis_numeric_only_true(self, interp_method, request, using_array_manage if interpolation == "nearest": expected = expected.astype(np.int64) if method == "table" and using_array_manager: - request.node.add_marker( - pytest.mark.xfail(reason="Axis name incorrectly set.") - ) + request.applymarker(pytest.mark.xfail(reason="Axis name incorrectly set.")) tm.assert_series_equal(result, expected) def test_quantile_date_range(self, interp_method, request, using_array_manager): @@ -170,9 +164,7 @@ def test_quantile_date_range(self, interp_method, request, using_array_manager): ["2016-01-02 00:00:00"], name=0.5, dtype="datetime64[ns, US/Pacific]" ) if method == "table" and using_array_manager: - request.node.add_marker( - pytest.mark.xfail(reason="Axis name incorrectly set.") - ) + request.applymarker(pytest.mark.xfail(reason="Axis name incorrectly set.")) tm.assert_series_equal(result, expected) @@ -194,9 +186,7 @@ def test_quantile_axis_mixed(self, interp_method, request, using_array_manager): if interpolation == "nearest": expected -= 0.5 if method == "table" and using_array_manager: - request.node.add_marker( - pytest.mark.xfail(reason="Axis name incorrectly set.") - ) + request.applymarker(pytest.mark.xfail(reason="Axis name incorrectly set.")) tm.assert_series_equal(result, expected) # must raise @@ -208,9 +198,7 @@ def test_quantile_axis_parameter(self, interp_method, request, using_array_manag # GH 9543/9544 interpolation, method = interp_method if method == "table" and using_array_manager: - request.node.add_marker( - pytest.mark.xfail(reason="Axis name incorrectly set.") - ) + request.applymarker(pytest.mark.xfail(reason="Axis name incorrectly set.")) df = DataFrame({"A": [1, 2, 3], "B": [2, 3, 4]}, index=[1, 2, 3]) result = df.quantile(0.5, axis=0, interpolation=interpolation, method=method) @@ -336,9 +324,7 @@ def test_quantile_multi(self, interp_method, request, using_array_manager): if interpolation == "nearest": expected = expected.astype(np.int64) if method == "table" and using_array_manager: - request.node.add_marker( - pytest.mark.xfail(reason="Axis name incorrectly set.") - ) + request.applymarker(pytest.mark.xfail(reason="Axis name incorrectly set.")) tm.assert_frame_equal(result, expected) def test_quantile_multi_axis_1(self, interp_method, request, using_array_manager): @@ -353,9 +339,7 @@ def test_quantile_multi_axis_1(self, interp_method, request, using_array_manager if interpolation == "nearest": expected = expected.astype(np.int64) if method == "table" and using_array_manager: - request.node.add_marker( - pytest.mark.xfail(reason="Axis name incorrectly set.") - ) + request.applymarker(pytest.mark.xfail(reason="Axis name incorrectly set.")) tm.assert_frame_equal(result, expected) def test_quantile_multi_empty(self, interp_method): @@ -458,9 +442,7 @@ def test_quantile_invalid(self, invalid, datetime_frame, interp_method): def test_quantile_box(self, interp_method, request, using_array_manager): interpolation, method = interp_method if method == "table" and using_array_manager: - request.node.add_marker( - pytest.mark.xfail(reason="Axis name incorrectly set.") - ) + request.applymarker(pytest.mark.xfail(reason="Axis name incorrectly set.")) df = DataFrame( { "A": [ @@ -591,9 +573,7 @@ def test_quantile_box_nat(self): def test_quantile_nan(self, interp_method, request, using_array_manager): interpolation, method = interp_method if method == "table" and using_array_manager: - request.node.add_marker( - pytest.mark.xfail(reason="Axis name incorrectly set.") - ) + request.applymarker(pytest.mark.xfail(reason="Axis name incorrectly set.")) # GH 14357 - float block where some cols have missing values df = DataFrame({"a": np.arange(1, 6.0), "b": np.arange(1, 6.0)}) df.iloc[-1, 1] = np.nan @@ -640,9 +620,7 @@ def test_quantile_nan(self, interp_method, request, using_array_manager): def test_quantile_nat(self, interp_method, request, using_array_manager): interpolation, method = interp_method if method == "table" and using_array_manager: - request.node.add_marker( - pytest.mark.xfail(reason="Axis name incorrectly set.") - ) + request.applymarker(pytest.mark.xfail(reason="Axis name incorrectly set.")) # full NaT column df = DataFrame({"a": [pd.NaT, pd.NaT, pd.NaT]}) diff --git a/pandas/tests/frame/methods/test_sort_values.py b/pandas/tests/frame/methods/test_sort_values.py index bd7d882f6d94a..f2f02058a534e 100644 --- a/pandas/tests/frame/methods/test_sort_values.py +++ b/pandas/tests/frame/methods/test_sort_values.py @@ -863,7 +863,7 @@ def test_sort_index_level_and_column_label( Version(np.__version__) >= Version("1.25") and request.node.callspec.id == "df_idx0-inner-True" ): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=( "pandas default unstable sorting of duplicates" @@ -907,7 +907,7 @@ def test_sort_column_level_and_index_label( result = df_idx.T.sort_values(by=sort_names, ascending=ascending, axis=1) if Version(np.__version__) >= Version("1.25"): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=( "pandas default unstable sorting of duplicates" diff --git a/pandas/tests/frame/methods/test_to_dict_of_blocks.py b/pandas/tests/frame/methods/test_to_dict_of_blocks.py index 906e74230a762..9d90111be6075 100644 --- a/pandas/tests/frame/methods/test_to_dict_of_blocks.py +++ b/pandas/tests/frame/methods/test_to_dict_of_blocks.py @@ -52,7 +52,7 @@ def test_no_copy_blocks(self, float_frame, using_copy_on_write): def test_to_dict_of_blocks_item_cache(request, using_copy_on_write): if using_copy_on_write: - request.node.add_marker(pytest.mark.xfail(reason="CoW - not yet implemented")) + request.applymarker(pytest.mark.xfail(reason="CoW - not yet implemented")) # Calling to_dict_of_blocks should not poison item_cache df = DataFrame({"a": [1, 2, 3, 4], "b": ["a", "b", "c", "d"]}) df["c"] = NumpyExtensionArray(np.array([1, 2, None, 3], dtype=object)) diff --git a/pandas/tests/frame/test_arithmetic.py b/pandas/tests/frame/test_arithmetic.py index 09a5cda4b3458..1d1a4dbe83a9c 100644 --- a/pandas/tests/frame/test_arithmetic.py +++ b/pandas/tests/frame/test_arithmetic.py @@ -508,7 +508,7 @@ def test_floordiv_axis0_numexpr_path(self, opname, request): and opname == "pow" and "python" in request.node.callspec.id ): - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason="https://github.com/pydata/numexpr/issues/454") ) diff --git a/pandas/tests/frame/test_constructors.py b/pandas/tests/frame/test_constructors.py index 3d8053703e906..4307cfc1e1d4e 100644 --- a/pandas/tests/frame/test_constructors.py +++ b/pandas/tests/frame/test_constructors.py @@ -3171,7 +3171,7 @@ def test_from_out_of_bounds_ns_datetime( "non-nano, but DatetimeArray._from_sequence has not", strict=True, ) - request.node.add_marker(mark) + request.applymarker(mark) scalar = datetime(9999, 1, 1) exp_dtype = "M8[us]" # pydatetime objects default to this reso @@ -3207,7 +3207,7 @@ def test_from_out_of_bounds_ns_timedelta( "to non-nano, but TimedeltaArray._from_sequence has not", strict=True, ) - request.node.add_marker(mark) + request.applymarker(mark) scalar = datetime(9999, 1, 1) - datetime(1970, 1, 1) exp_dtype = "m8[us]" # smallest reso that fits diff --git a/pandas/tests/frame/test_reductions.py b/pandas/tests/frame/test_reductions.py index a17dc4a789fe3..b42f2148f90d5 100644 --- a/pandas/tests/frame/test_reductions.py +++ b/pandas/tests/frame/test_reductions.py @@ -729,7 +729,7 @@ def test_std_datetime64_with_nat( mark = pytest.mark.xfail( reason="GH#51446: Incorrect type inference on NaT in reduction result" ) - request.node.add_marker(mark) + request.applymarker(mark) df = DataFrame({"a": to_datetime(values)}) result = df.std(skipna=skipna) if not skipna or all(value is pd.NaT for value in values): @@ -1594,7 +1594,7 @@ def test_reductions_skipna_none_raises( self, request, frame_or_series, all_reductions ): if all_reductions == "count": - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason="Count does not accept skipna") ) obj = frame_or_series([1, 2, 3]) @@ -1822,7 +1822,7 @@ def test_sum_timedelta64_skipna_false(using_array_manager, request): mark = pytest.mark.xfail( reason="Incorrect type inference on NaT in reduction result" ) - request.node.add_marker(mark) + request.applymarker(mark) arr = np.arange(8).astype(np.int64).view("m8[s]").reshape(4, 2) arr[-1, -1] = "Nat" diff --git a/pandas/tests/frame/test_ufunc.py b/pandas/tests/frame/test_ufunc.py index 305c0f8bba8ce..88c62da2b0a73 100644 --- a/pandas/tests/frame/test_ufunc.py +++ b/pandas/tests/frame/test_ufunc.py @@ -31,7 +31,7 @@ def test_unary_unary(dtype): def test_unary_binary(request, dtype): # unary input, binary output if is_extension_array_dtype(dtype) or isinstance(dtype, dict): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Extension / mixed with multiple outputs not implemented." ) @@ -106,7 +106,7 @@ def test_binary_input_aligns_columns(request, dtype_a, dtype_b): or is_extension_array_dtype(dtype_b) or isinstance(dtype_b, dict) ): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Extension / mixed with multiple inputs not implemented." ) @@ -135,7 +135,7 @@ def test_binary_input_aligns_columns(request, dtype_a, dtype_b): @pytest.mark.parametrize("dtype", dtypes) def test_binary_input_aligns_index(request, dtype): if is_extension_array_dtype(dtype) or isinstance(dtype, dict): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Extension / mixed with multiple inputs not implemented." ) diff --git a/pandas/tests/generic/test_duplicate_labels.py b/pandas/tests/generic/test_duplicate_labels.py index a81e013290b64..cb21ac6b83ee9 100644 --- a/pandas/tests/generic/test_duplicate_labels.py +++ b/pandas/tests/generic/test_duplicate_labels.py @@ -92,7 +92,7 @@ def test_preserve_getitem(self): def test_ndframe_getitem_caching_issue(self, request, using_copy_on_write): if not using_copy_on_write: - request.node.add_marker(pytest.mark.xfail(reason="Unclear behavior.")) + request.applymarker(pytest.mark.xfail(reason="Unclear behavior.")) # NDFrame.__getitem__ will cache the first df['A']. May need to # invalidate that cache? Update the cached entries? df = pd.DataFrame({"A": [0]}).set_flags(allows_duplicate_labels=False) diff --git a/pandas/tests/generic/test_finalize.py b/pandas/tests/generic/test_finalize.py index 0f7ae998a4b2b..68746b9e9a803 100644 --- a/pandas/tests/generic/test_finalize.py +++ b/pandas/tests/generic/test_finalize.py @@ -490,7 +490,7 @@ def test_binops(request, args, annotate, all_binary_operators): if not (isinstance(left, int) or isinstance(right, int)) and annotate != "both": if not all_binary_operators.__name__.startswith("r"): if annotate == "right" and isinstance(left, type(right)): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=f"{all_binary_operators} doesn't work when right has " f"attrs and both are {type(left)}" @@ -498,14 +498,14 @@ def test_binops(request, args, annotate, all_binary_operators): ) if not isinstance(left, type(right)): if annotate == "left" and isinstance(left, pd.Series): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=f"{all_binary_operators} doesn't work when the " "objects are different Series has attrs" ) ) elif annotate == "right" and isinstance(right, pd.Series): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=f"{all_binary_operators} doesn't work when the " "objects are different Series has attrs" @@ -513,7 +513,7 @@ def test_binops(request, args, annotate, all_binary_operators): ) else: if annotate == "left" and isinstance(left, type(right)): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=f"{all_binary_operators} doesn't work when left has " f"attrs and both are {type(left)}" @@ -521,14 +521,14 @@ def test_binops(request, args, annotate, all_binary_operators): ) if not isinstance(left, type(right)): if annotate == "right" and isinstance(right, pd.Series): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=f"{all_binary_operators} doesn't work when the " "objects are different Series has attrs" ) ) elif annotate == "left" and isinstance(left, pd.Series): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=f"{all_binary_operators} doesn't work when the " "objects are different Series has attrs" diff --git a/pandas/tests/groupby/methods/test_quantile.py b/pandas/tests/groupby/methods/test_quantile.py index 4e7c09b70feb0..fcb9701e9881b 100644 --- a/pandas/tests/groupby/methods/test_quantile.py +++ b/pandas/tests/groupby/methods/test_quantile.py @@ -45,7 +45,7 @@ def test_quantile(interpolation, a_vals, b_vals, q, request): and isinstance(b_vals, list) and b_vals == [4, 3, 2, 1] ): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Unclear numpy expectation for nearest " "result with equidistant data" diff --git a/pandas/tests/groupby/methods/test_value_counts.py b/pandas/tests/groupby/methods/test_value_counts.py index 45a33d3b70f71..c1ee107715b71 100644 --- a/pandas/tests/groupby/methods/test_value_counts.py +++ b/pandas/tests/groupby/methods/test_value_counts.py @@ -249,7 +249,7 @@ def test_bad_subset(education_df): def test_basic(education_df, request): # gh43564 if Version(np.__version__) >= Version("1.25"): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=( "pandas default unstable sorting of duplicates" @@ -306,7 +306,7 @@ def test_against_frame_and_seriesgroupby( # - apply with :meth:`~DataFrame.value_counts` # - `~SeriesGroupBy.value_counts` if Version(np.__version__) >= Version("1.25") and frame and sort and normalize: - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=( "pandas default unstable sorting of duplicates" @@ -482,7 +482,7 @@ def test_dropna_combinations( nulls_df, group_dropna, count_dropna, expected_rows, expected_values, request ): if Version(np.__version__) >= Version("1.25") and not group_dropna: - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=( "pandas default unstable sorting of duplicates" @@ -586,7 +586,7 @@ def test_categorical_single_grouper_with_only_observed_categories( # Test single categorical grouper with only observed grouping categories # when non-groupers are also categorical if Version(np.__version__) >= Version("1.25"): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=( "pandas default unstable sorting of duplicates" @@ -695,7 +695,7 @@ def test_categorical_single_grouper_observed_true( # GH#46357 if Version(np.__version__) >= Version("1.25"): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=( "pandas default unstable sorting of duplicates" @@ -776,7 +776,7 @@ def test_categorical_single_grouper_observed_false( # GH#46357 if Version(np.__version__) >= Version("1.25"): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=( "pandas default unstable sorting of duplicates" @@ -929,7 +929,7 @@ def test_categorical_non_groupers( # regardless of `observed` if Version(np.__version__) >= Version("1.25"): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=( "pandas default unstable sorting of duplicates" diff --git a/pandas/tests/groupby/test_categorical.py b/pandas/tests/groupby/test_categorical.py index 11291bb89b604..939dd176ae90e 100644 --- a/pandas/tests/groupby/test_categorical.py +++ b/pandas/tests/groupby/test_categorical.py @@ -1443,7 +1443,7 @@ def test_series_groupby_on_2_categoricals_unobserved_zeroes_or_nans( mark = pytest.mark.xfail( reason="TODO: implemented SeriesGroupBy.corrwith. See GH 32293" ) - request.node.add_marker(mark) + request.applymarker(mark) df = DataFrame( { @@ -1912,7 +1912,7 @@ def test_category_order_reducer( # GH#48749 if reduction_func == "corrwith" and not as_index: msg = "GH#49950 - corrwith with as_index=False may not have grouping column" - request.node.add_marker(pytest.mark.xfail(reason=msg)) + request.applymarker(pytest.mark.xfail(reason=msg)) elif index_kind != "range" and not as_index: pytest.skip(reason="Result doesn't have categories, nothing to test") df = DataFrame( @@ -2123,7 +2123,7 @@ def test_agg_list(request, as_index, observed, reduction_func, test_series, keys pytest.skip("corrwith not implemented for SeriesGroupBy") elif reduction_func == "corrwith": msg = "GH#32293: attempts to call SeriesGroupBy.corrwith" - request.node.add_marker(pytest.mark.xfail(reason=msg)) + request.applymarker(pytest.mark.xfail(reason=msg)) elif ( reduction_func == "nunique" and not test_series @@ -2132,7 +2132,7 @@ def test_agg_list(request, as_index, observed, reduction_func, test_series, keys and not as_index ): msg = "GH#52848 - raises a ValueError" - request.node.add_marker(pytest.mark.xfail(reason=msg)) + request.applymarker(pytest.mark.xfail(reason=msg)) df = DataFrame({"a1": [0, 0, 1], "a2": [2, 3, 3], "b": [4, 5, 6]}) df = df.astype({"a1": "category", "a2": "category"}) diff --git a/pandas/tests/groupby/test_function.py b/pandas/tests/groupby/test_function.py index 4876267c72f12..b840443aab347 100644 --- a/pandas/tests/groupby/test_function.py +++ b/pandas/tests/groupby/test_function.py @@ -418,7 +418,7 @@ def test_axis1_numeric_only(request, groupby_func, numeric_only): pytest.skip("idxmax and idx_min tested in test_idxmin_idxmax_axis1") if groupby_func in ("corrwith", "skew"): msg = "GH#47723 groupby.corrwith and skew do not correctly implement axis=1" - request.node.add_marker(pytest.mark.xfail(reason=msg)) + request.applymarker(pytest.mark.xfail(reason=msg)) df = DataFrame( np.random.default_rng(2).standard_normal((10, 4)), columns=["A", "B", "C", "D"] @@ -822,7 +822,7 @@ def test_duplicate_columns(request, groupby_func, as_index): # GH#50806 if groupby_func == "corrwith": msg = "GH#50845 - corrwith fails when there are duplicate columns" - request.node.add_marker(pytest.mark.xfail(reason=msg)) + request.applymarker(pytest.mark.xfail(reason=msg)) df = DataFrame([[1, 3, 6], [1, 4, 7], [2, 5, 8]], columns=list("abb")) args = get_groupby_method_args(groupby_func, df) gb = df.groupby("a", as_index=as_index) diff --git a/pandas/tests/groupby/test_groupby_dropna.py b/pandas/tests/groupby/test_groupby_dropna.py index 8065aa63dff81..ab3920d18374b 100644 --- a/pandas/tests/groupby/test_groupby_dropna.py +++ b/pandas/tests/groupby/test_groupby_dropna.py @@ -591,7 +591,7 @@ def test_categorical_transformers( # GH#36327 if transformation_func == "fillna": msg = "GH#49651 fillna may incorrectly reorders results when dropna=False" - request.node.add_marker(pytest.mark.xfail(reason=msg, strict=False)) + request.applymarker(pytest.mark.xfail(reason=msg, strict=False)) values = np.append(np.random.default_rng(2).choice([1, 2, None], size=19), None) df = pd.DataFrame( diff --git a/pandas/tests/groupby/transform/test_transform.py b/pandas/tests/groupby/transform/test_transform.py index 4a493ef3fd52c..add3c94dcd36a 100644 --- a/pandas/tests/groupby/transform/test_transform.py +++ b/pandas/tests/groupby/transform/test_transform.py @@ -203,7 +203,7 @@ def test_transform_axis_1_reducer(request, reduction_func): "nth", ): marker = pytest.mark.xfail(reason="transform incorrectly fails - GH#45986") - request.node.add_marker(marker) + request.applymarker(marker) df = DataFrame({"a": [1, 2], "b": [3, 4], "c": [5, 6]}, index=["x", "y"]) msg = "DataFrame.groupby with axis=1 is deprecated" @@ -1455,7 +1455,7 @@ def test_null_group_str_reducer(request, dropna, reduction_func): # GH 17093 if reduction_func == "corrwith": msg = "incorrectly raises" - request.node.add_marker(pytest.mark.xfail(reason=msg)) + request.applymarker(pytest.mark.xfail(reason=msg)) index = [1, 2, 3, 4] # test transform preserves non-standard index df = DataFrame({"A": [1, 1, np.nan, np.nan], "B": [1, 2, 2, 3]}, index=index) diff --git a/pandas/tests/indexes/datetimes/test_ops.py b/pandas/tests/indexes/datetimes/test_ops.py index 7eea05c753b8a..c58d55ad6371b 100644 --- a/pandas/tests/indexes/datetimes/test_ops.py +++ b/pandas/tests/indexes/datetimes/test_ops.py @@ -34,7 +34,7 @@ class TestDatetimeIndexOps: def test_resolution(self, request, tz_naive_fixture, freq, expected): tz = tz_naive_fixture if freq == "Y" and not IS64 and isinstance(tz, tzlocal): - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason="OverflowError inside tzlocal past 2038") ) diff --git a/pandas/tests/indexes/test_common.py b/pandas/tests/indexes/test_common.py index 6245a129afedc..412a59d15307d 100644 --- a/pandas/tests/indexes/test_common.py +++ b/pandas/tests/indexes/test_common.py @@ -258,7 +258,7 @@ def test_searchsorted_monotonic(self, index_flat, request): reason="IntervalIndex.searchsorted does not support Interval arg", raises=NotImplementedError, ) - request.node.add_marker(mark) + request.applymarker(mark) # nothing to test if the index is empty if index.empty: @@ -459,7 +459,7 @@ def test_sort_values_with_missing(index_with_missing, na_position, request): # sort non-missing and place missing according to na_position if isinstance(index_with_missing, CategoricalIndex): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="missing value sorting order not well-defined", strict=False ) diff --git a/pandas/tests/indexes/test_index_new.py b/pandas/tests/indexes/test_index_new.py index d35c35661051a..b6de73266dc34 100644 --- a/pandas/tests/indexes/test_index_new.py +++ b/pandas/tests/indexes/test_index_new.py @@ -146,7 +146,7 @@ def test_constructor_infer_nat_dt_like( if nulls_fixture is NA: expected = Index([NA, NaT]) mark = pytest.mark.xfail(reason="Broken with np.NaT ctor; see GH 31884") - request.node.add_marker(mark) + request.applymarker(mark) # GH#35942 numpy will emit a DeprecationWarning within the # assert_index_equal calls. Since we can't do anything # about it until GH#31884 is fixed, we suppress that warning. diff --git a/pandas/tests/indexes/test_setops.py b/pandas/tests/indexes/test_setops.py index d6304774b87c4..1dfeb4f2c6b5b 100644 --- a/pandas/tests/indexes/test_setops.py +++ b/pandas/tests/indexes/test_setops.py @@ -64,7 +64,7 @@ def test_union_different_types(index_flat, index_flat2, request): mark = pytest.mark.xfail( reason="GH#44000 True==1", raises=ValueError, strict=False ) - request.node.add_marker(mark) + request.applymarker(mark) common_dtype = find_common_type([idx1.dtype, idx2.dtype]) @@ -89,7 +89,7 @@ def test_union_different_types(index_flat, index_flat2, request): raises=AssertionError, strict=False, ) - request.node.add_marker(mark) + request.applymarker(mark) any_uint64 = np.uint64 in (idx1.dtype, idx2.dtype) idx1_signed = is_signed_integer_dtype(idx1.dtype) diff --git a/pandas/tests/indexing/test_loc.py b/pandas/tests/indexing/test_loc.py index 70eada188f3c8..6836e9a7c390e 100644 --- a/pandas/tests/indexing/test_loc.py +++ b/pandas/tests/indexing/test_loc.py @@ -1124,7 +1124,7 @@ def test_loc_copy_vs_view(self, request, using_copy_on_write): if not using_copy_on_write: mark = pytest.mark.xfail(reason="accidental fix reverted - GH37497") - request.node.add_marker(mark) + request.applymarker(mark) x = DataFrame(zip(range(3), range(3)), columns=["a", "b"]) y = x.copy() diff --git a/pandas/tests/io/excel/test_readers.py b/pandas/tests/io/excel/test_readers.py index 8dd9f96a05a90..c5bf935b0d54d 100644 --- a/pandas/tests/io/excel/test_readers.py +++ b/pandas/tests/io/excel/test_readers.py @@ -197,7 +197,7 @@ def test_usecols_int(self, read_ext): def test_usecols_list(self, request, engine, read_ext, df_ref): if engine == "pyxlsb": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Sheets containing datetimes not supported by pyxlsb" ) @@ -221,7 +221,7 @@ def test_usecols_list(self, request, engine, read_ext, df_ref): def test_usecols_str(self, request, engine, read_ext, df_ref): if engine == "pyxlsb": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Sheets containing datetimes not supported by pyxlsb" ) @@ -279,7 +279,7 @@ def test_usecols_diff_positional_int_columns_order( self, request, engine, read_ext, usecols, df_ref ): if engine == "pyxlsb": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Sheets containing datetimes not supported by pyxlsb" ) @@ -301,7 +301,7 @@ def test_usecols_diff_positional_str_columns_order(self, read_ext, usecols, df_r def test_read_excel_without_slicing(self, request, engine, read_ext, df_ref): if engine == "pyxlsb": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Sheets containing datetimes not supported by pyxlsb" ) @@ -313,7 +313,7 @@ def test_read_excel_without_slicing(self, request, engine, read_ext, df_ref): def test_usecols_excel_range_str(self, request, engine, read_ext, df_ref): if engine == "pyxlsb": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Sheets containing datetimes not supported by pyxlsb" ) @@ -401,7 +401,7 @@ def test_excel_stop_iterator(self, read_ext): def test_excel_cell_error_na(self, request, engine, read_ext): if engine == "pyxlsb": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Sheets containing datetimes not supported by pyxlsb" ) @@ -409,7 +409,7 @@ def test_excel_cell_error_na(self, request, engine, read_ext): # https://github.com/tafia/calamine/issues/355 if engine == "calamine" and read_ext == ".ods": - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason="Calamine can't extract error from ods files") ) @@ -419,7 +419,7 @@ def test_excel_cell_error_na(self, request, engine, read_ext): def test_excel_table(self, request, engine, read_ext, df_ref): if engine == "pyxlsb": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Sheets containing datetimes not supported by pyxlsb" ) @@ -440,7 +440,7 @@ def test_excel_table(self, request, engine, read_ext, df_ref): def test_reader_special_dtypes(self, request, engine, read_ext): if engine == "pyxlsb": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Sheets containing datetimes not supported by pyxlsb" ) @@ -778,7 +778,7 @@ def test_exception_message_includes_sheet_name(self, read_ext): def test_date_conversion_overflow(self, request, engine, read_ext): # GH 10001 : pandas.ExcelFile ignore parse_dates=False if engine == "pyxlsb": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Sheets containing datetimes not supported by pyxlsb" ) @@ -794,13 +794,13 @@ def test_date_conversion_overflow(self, request, engine, read_ext): ) if engine == "openpyxl": - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason="Maybe not supported by openpyxl") ) if engine is None and read_ext in (".xlsx", ".xlsm"): # GH 35029 - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason="Defaults to openpyxl, maybe not supported") ) @@ -809,7 +809,7 @@ def test_date_conversion_overflow(self, request, engine, read_ext): def test_sheet_name(self, request, read_ext, engine, df_ref): if engine == "pyxlsb": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Sheets containing datetimes not supported by pyxlsb" ) @@ -975,7 +975,7 @@ def test_close_from_py_localpath(self, read_ext): def test_reader_seconds(self, request, engine, read_ext): if engine == "pyxlsb": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Sheets containing datetimes not supported by pyxlsb" ) @@ -983,7 +983,7 @@ def test_reader_seconds(self, request, engine, read_ext): # GH 55045 if engine == "calamine" and read_ext == ".ods": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="ODS file contains bad datetime (seconds as text)" ) @@ -1017,7 +1017,7 @@ def test_reader_seconds(self, request, engine, read_ext): def test_read_excel_multiindex(self, request, engine, read_ext): # see gh-4679 if engine == "pyxlsb": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Sheets containing datetimes not supported by pyxlsb" ) @@ -1025,9 +1025,7 @@ def test_read_excel_multiindex(self, request, engine, read_ext): # https://github.com/tafia/calamine/issues/354 if engine == "calamine" and read_ext == ".ods": - request.node.add_marker( - pytest.mark.xfail(reason="Last test fails in calamine") - ) + request.applymarker(pytest.mark.xfail(reason="Last test fails in calamine")) mi = MultiIndex.from_product([["foo", "bar"], ["a", "b"]]) mi_file = "testmultiindex" + read_ext @@ -1118,7 +1116,7 @@ def test_read_excel_multiindex_blank_after_name( ): # GH34673 if engine == "pyxlsb": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Sheets containing datetimes not supported by pyxlsb (GH4679" ) @@ -1241,7 +1239,7 @@ def test_read_excel_bool_header_arg(self, read_ext): def test_read_excel_skiprows(self, request, engine, read_ext): # GH 4903 if engine == "pyxlsb": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Sheets containing datetimes not supported by pyxlsb" ) @@ -1296,7 +1294,7 @@ def test_read_excel_skiprows(self, request, engine, read_ext): def test_read_excel_skiprows_callable_not_in(self, request, engine, read_ext): # GH 4903 if engine == "pyxlsb": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Sheets containing datetimes not supported by pyxlsb" ) @@ -1426,7 +1424,7 @@ def test_ignore_chartsheets_by_str(self, request, engine, read_ext): if read_ext == ".ods": pytest.skip("chartsheets do not exist in the ODF format") if engine == "pyxlsb": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="pyxlsb can't distinguish chartsheets from worksheets" ) @@ -1439,7 +1437,7 @@ def test_ignore_chartsheets_by_int(self, request, engine, read_ext): if read_ext == ".ods": pytest.skip("chartsheets do not exist in the ODF format") if engine == "pyxlsb": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="pyxlsb can't distinguish chartsheets from worksheets" ) @@ -1568,7 +1566,7 @@ def test_excel_passes_na_filter(self, read_ext, na_filter): def test_excel_table_sheet_by_index(self, request, engine, read_ext, df_ref): if engine == "pyxlsb": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Sheets containing datetimes not supported by pyxlsb" ) @@ -1597,7 +1595,7 @@ def test_excel_table_sheet_by_index(self, request, engine, read_ext, df_ref): def test_sheet_name(self, request, engine, read_ext, df_ref): if engine == "pyxlsb": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Sheets containing datetimes not supported by pyxlsb" ) @@ -1689,7 +1687,7 @@ def test_header_with_index_col(self, filename): def test_read_datetime_multiindex(self, request, engine, read_ext): # GH 34748 if engine == "pyxlsb": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Sheets containing datetimes not supported by pyxlsb" ) @@ -1720,7 +1718,7 @@ def test_ignore_chartsheets(self, request, engine, read_ext): if read_ext == ".ods": pytest.skip("chartsheets do not exist in the ODF format") if engine == "pyxlsb": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="pyxlsb can't distinguish chartsheets from worksheets" ) diff --git a/pandas/tests/io/excel/test_writers.py b/pandas/tests/io/excel/test_writers.py index 18af18ade85f4..946c621ae2b6e 100644 --- a/pandas/tests/io/excel/test_writers.py +++ b/pandas/tests/io/excel/test_writers.py @@ -217,7 +217,7 @@ def test_excel_multindex_roundtrip( reason="Column index name cannot be serialized unless " "it's a MultiIndex" ) - request.node.add_marker(mark) + request.applymarker(mark) # Empty name case current read in as # unnamed levels, not Nones. diff --git a/pandas/tests/io/json/test_pandas.py b/pandas/tests/io/json/test_pandas.py index 2767078674632..7312facc44c26 100644 --- a/pandas/tests/io/json/test_pandas.py +++ b/pandas/tests/io/json/test_pandas.py @@ -242,7 +242,7 @@ def test_roundtrip_categorical( ): # TODO: create a better frame to test with and improve coverage if orient in ("index", "columns"): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=f"Can't have duplicate index values for orient '{orient}')" ) @@ -1893,7 +1893,7 @@ def test_json_pandas_nulls(self, nulls_fixture, request): # GH 31615 if isinstance(nulls_fixture, Decimal): mark = pytest.mark.xfail(reason="not implemented") - request.node.add_marker(mark) + request.applymarker(mark) result = DataFrame([[nulls_fixture]]).to_json() assert result == '{"0":{"0":null}}' diff --git a/pandas/tests/io/json/test_readlines.py b/pandas/tests/io/json/test_readlines.py index d7baba87bba31..124d6890886a8 100644 --- a/pandas/tests/io/json/test_readlines.py +++ b/pandas/tests/io/json/test_readlines.py @@ -43,7 +43,7 @@ def test_read_datetime(request, engine): if engine == "pyarrow": # GH 48893 reason = "Pyarrow only supports a file path as an input and line delimited json" - request.node.add_marker(pytest.mark.xfail(reason=reason, raises=ValueError)) + request.applymarker(pytest.mark.xfail(reason=reason, raises=ValueError)) df = DataFrame( [([1, 2], ["2020-03-05", "2020-04-08T09:58:49+00:00"], "hector")], @@ -121,7 +121,7 @@ def test_readjson_chunks(request, lines_json_df, chunksize, engine): "Pyarrow only supports a file path as an input and line delimited json" "and doesn't support chunksize parameter." ) - request.node.add_marker(pytest.mark.xfail(reason=reason, raises=ValueError)) + request.applymarker(pytest.mark.xfail(reason=reason, raises=ValueError)) unchunked = read_json(StringIO(lines_json_df), lines=True) with read_json( @@ -148,7 +148,7 @@ def test_readjson_chunks_series(request, engine): "Pyarrow only supports a file path as an input and line delimited json" "and doesn't support chunksize parameter." ) - request.node.add_marker(pytest.mark.xfail(reason=reason)) + request.applymarker(pytest.mark.xfail(reason=reason)) # Test reading line-format JSON to Series with chunksize param s = pd.Series({"A": 1, "B": 2}) @@ -172,7 +172,7 @@ def test_readjson_each_chunk(request, lines_json_df, engine): "Pyarrow only supports a file path as an input and line delimited json" "and doesn't support chunksize parameter." ) - request.node.add_marker(pytest.mark.xfail(reason=reason, raises=ValueError)) + request.applymarker(pytest.mark.xfail(reason=reason, raises=ValueError)) # Other tests check that the final result of read_json(chunksize=True) # is correct. This checks the intermediate chunks. @@ -191,7 +191,7 @@ def test_readjson_chunks_from_file(request, engine): "Pyarrow only supports a file path as an input and line delimited json" "and doesn't support chunksize parameter." ) - request.node.add_marker(pytest.mark.xfail(reason=reason, raises=ValueError)) + request.applymarker(pytest.mark.xfail(reason=reason, raises=ValueError)) with tm.ensure_clean("test.json") as path: df = DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]}) @@ -274,7 +274,7 @@ def test_readjson_unicode(request, monkeypatch, engine): "Pyarrow only supports a file path as an input and line delimited json" "and doesn't support chunksize parameter." ) - request.node.add_marker(pytest.mark.xfail(reason=reason, raises=ValueError)) + request.applymarker(pytest.mark.xfail(reason=reason, raises=ValueError)) with tm.ensure_clean("test.json") as path: monkeypatch.setattr("locale.getpreferredencoding", lambda do_setlocale: "cp949") @@ -309,7 +309,7 @@ def test_readjson_nrows_chunks(request, nrows, chunksize, engine): "Pyarrow only supports a file path as an input and line delimited json" "and doesn't support chunksize parameter." ) - request.node.add_marker(pytest.mark.xfail(reason=reason, raises=ValueError)) + request.applymarker(pytest.mark.xfail(reason=reason, raises=ValueError)) jsonl = """{"a": 1, "b": 2} {"a": 3, "b": 4} @@ -351,7 +351,7 @@ def test_readjson_lines_chunks_fileurl(request, datapath, engine): "Pyarrow only supports a file path as an input and line delimited json" "and doesn't support chunksize parameter." ) - request.node.add_marker(pytest.mark.xfail(reason=reason, raises=ValueError)) + request.applymarker(pytest.mark.xfail(reason=reason, raises=ValueError)) df_list_expected = [ DataFrame([[1, 2]], columns=["a", "b"], index=[0]), diff --git a/pandas/tests/io/parser/common/test_float.py b/pandas/tests/io/parser/common/test_float.py index 2ca98de914f9e..8ec372420a0f0 100644 --- a/pandas/tests/io/parser/common/test_float.py +++ b/pandas/tests/io/parser/common/test_float.py @@ -55,7 +55,7 @@ def test_too_many_exponent_digits(all_parsers_all_precisions, exp, request): if precision == "round_trip": if exp == 999999999999999999 and is_platform_linux(): mark = pytest.mark.xfail(reason="GH38794, on Linux gives object result") - request.node.add_marker(mark) + request.applymarker(mark) value = np.inf if exp > 0 else 0.0 expected = DataFrame({"data": [value]}) diff --git a/pandas/tests/io/parser/common/test_read_errors.py b/pandas/tests/io/parser/common/test_read_errors.py index 4e82dca83e2d0..ff1af6e2dc81b 100644 --- a/pandas/tests/io/parser/common/test_read_errors.py +++ b/pandas/tests/io/parser/common/test_read_errors.py @@ -210,7 +210,7 @@ def test_null_byte_char(request, all_parsers): if parser.engine == "c" or (parser.engine == "python" and PY311): if parser.engine == "python" and PY311: - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="In Python 3.11, this is read as an empty character not null" ) @@ -230,7 +230,7 @@ def test_open_file(request, all_parsers): # GH 39024 parser = all_parsers if parser.engine == "c": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=f"{parser.engine} engine does not support sep=None " f"with delim_whitespace=False" diff --git a/pandas/tests/io/parser/conftest.py b/pandas/tests/io/parser/conftest.py index 3ab40ff846cb6..591defdde7df9 100644 --- a/pandas/tests/io/parser/conftest.py +++ b/pandas/tests/io/parser/conftest.py @@ -278,7 +278,7 @@ def pyarrow_xfail(request): return if parser.engine == "pyarrow": mark = pytest.mark.xfail(reason="pyarrow doesn't support this.") - request.node.add_marker(mark) + request.applymarker(mark) @pytest.fixture diff --git a/pandas/tests/io/parser/dtypes/test_dtypes_basic.py b/pandas/tests/io/parser/dtypes/test_dtypes_basic.py index 97a32ad79a67c..8fb25fe3ee47e 100644 --- a/pandas/tests/io/parser/dtypes/test_dtypes_basic.py +++ b/pandas/tests/io/parser/dtypes/test_dtypes_basic.py @@ -234,7 +234,7 @@ def decimal_number_check(request, parser, numeric_decimal, thousands, float_prec # GH#31920 value = numeric_decimal[0] if thousands is None and value in ("1_,", "1_234,56", "1_234,56e0"): - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason=f"thousands={thousands} and sep is in {value}") ) df = parser.read_csv( diff --git a/pandas/tests/io/parser/test_comment.py b/pandas/tests/io/parser/test_comment.py index 9a14e67c154b6..5b738446ea441 100644 --- a/pandas/tests/io/parser/test_comment.py +++ b/pandas/tests/io/parser/test_comment.py @@ -45,7 +45,7 @@ def test_line_comment(all_parsers, read_kwargs, request): mark = pytest.mark.xfail( reason="Custom terminator not supported with Python engine" ) - request.node.add_marker(mark) + request.applymarker(mark) data = data.replace("\n", read_kwargs.get("lineterminator")) @@ -146,7 +146,7 @@ def test_comment_char_in_default_value(all_parsers, request): if all_parsers.engine == "c": reason = "see gh-34002: works on the python engine but not the c engine" # NA value containing comment char is interpreted as comment - request.node.add_marker(pytest.mark.xfail(reason=reason, raises=AssertionError)) + request.applymarker(pytest.mark.xfail(reason=reason, raises=AssertionError)) parser = all_parsers data = ( diff --git a/pandas/tests/io/parser/test_compression.py b/pandas/tests/io/parser/test_compression.py index d150b52258d47..1c67ec7c3066c 100644 --- a/pandas/tests/io/parser/test_compression.py +++ b/pandas/tests/io/parser/test_compression.py @@ -105,7 +105,7 @@ def test_compression( filename = filename if filename is None else filename.format(ext=ext) if filename and buffer: - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Cannot deduce compression from buffer of compressed data." ) diff --git a/pandas/tests/io/parser/test_encoding.py b/pandas/tests/io/parser/test_encoding.py index 3873bf31c1ed4..c09ab7898c67c 100644 --- a/pandas/tests/io/parser/test_encoding.py +++ b/pandas/tests/io/parser/test_encoding.py @@ -127,9 +127,7 @@ def _encode_data_with_bom(_data): and kwargs.get("skip_blank_lines", True) ): # Manually xfail, since we don't have mechanism to xfail specific version - request.node.add_marker( - pytest.mark.xfail(reason="Pyarrow can't read blank lines") - ) + request.applymarker(pytest.mark.xfail(reason="Pyarrow can't read blank lines")) result = parser.read_csv(_encode_data_with_bom(data), encoding=utf8, **kwargs) tm.assert_frame_equal(result, expected) diff --git a/pandas/tests/io/parser/test_index_col.py b/pandas/tests/io/parser/test_index_col.py index a7ded00e758b7..8213ea006614f 100644 --- a/pandas/tests/io/parser/test_index_col.py +++ b/pandas/tests/io/parser/test_index_col.py @@ -341,7 +341,7 @@ def test_specify_dtype_for_index_col(all_parsers, dtype, val, request): data = "a,b\n01,2" parser = all_parsers if dtype == object and parser.engine == "pyarrow": - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason="Cannot disable type-inference for pyarrow engine") ) result = parser.read_csv(StringIO(data), index_col="a", dtype={"a": dtype}) diff --git a/pandas/tests/io/parser/test_parse_dates.py b/pandas/tests/io/parser/test_parse_dates.py index 9f7840588f89e..bd08dd3a0c5d2 100644 --- a/pandas/tests/io/parser/test_parse_dates.py +++ b/pandas/tests/io/parser/test_parse_dates.py @@ -157,7 +157,7 @@ def test_multiple_date_col_custom(all_parsers, keep_date_col, request): mark = pytest.mark.xfail( reason="pyarrow doesn't support disabling auto-inference on column numbers." ) - request.node.add_marker(mark) + request.applymarker(mark) def date_parser(*date_cols): """ @@ -326,7 +326,7 @@ def test_multiple_date_col(all_parsers, keep_date_col, request): mark = pytest.mark.xfail( reason="pyarrow doesn't support disabling auto-inference on column numbers." ) - request.node.add_marker(mark) + request.applymarker(mark) kwds = { "header": None, @@ -1836,7 +1836,7 @@ def test_hypothesis_delimited_date( request, date_format, dayfirst, delimiter, test_datetime ): if date_format == "%m %Y" and delimiter == ".": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="parse_datetime_string cannot reliably tell whether " "e.g. %m.%Y is a float or a date" diff --git a/pandas/tests/io/parser/test_skiprows.py b/pandas/tests/io/parser/test_skiprows.py index c58e27aacfa00..4b509edc36925 100644 --- a/pandas/tests/io/parser/test_skiprows.py +++ b/pandas/tests/io/parser/test_skiprows.py @@ -204,7 +204,7 @@ def test_skiprows_lineterminator(all_parsers, lineterminator, request): if parser.engine == "python" and lineterminator == "\r": mark = pytest.mark.xfail(reason="'CR' not respect with the Python parser yet") - request.node.add_marker(mark) + request.applymarker(mark) data = data.replace("\n", lineterminator) result = parser.read_csv( diff --git a/pandas/tests/io/parser/test_unsupported.py b/pandas/tests/io/parser/test_unsupported.py index b489c09e917af..f201f6c394566 100644 --- a/pandas/tests/io/parser/test_unsupported.py +++ b/pandas/tests/io/parser/test_unsupported.py @@ -190,7 +190,7 @@ def test_invalid_file_inputs(request, all_parsers): # GH#45957 parser = all_parsers if parser.engine == "python": - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason=f"{parser.engine} engine supports lists.") ) diff --git a/pandas/tests/io/pytables/test_round_trip.py b/pandas/tests/io/pytables/test_round_trip.py index 48983cbb5ec28..af24a5cf7e0ab 100644 --- a/pandas/tests/io/pytables/test_round_trip.py +++ b/pandas/tests/io/pytables/test_round_trip.py @@ -331,7 +331,7 @@ def test_timeseries_preepoch(setup_path, request): _check_roundtrip(ts, tm.assert_series_equal, path=setup_path) except OverflowError: if is_platform_windows(): - request.node.add_marker( + request.applymarker( pytest.mark.xfail("known failure on some windows platforms") ) raise diff --git a/pandas/tests/io/test_parquet.py b/pandas/tests/io/test_parquet.py index b043f9fab23ae..1538275e6af73 100644 --- a/pandas/tests/io/test_parquet.py +++ b/pandas/tests/io/test_parquet.py @@ -453,7 +453,7 @@ def test_read_filters(self, engine, tmp_path): def test_write_index(self, engine, using_copy_on_write, request): check_names = engine != "fastparquet" if using_copy_on_write and engine == "fastparquet": - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason="fastparquet write into index") ) @@ -626,7 +626,7 @@ def test_dtype_backend(self, engine, request): mark = pytest.mark.xfail( reason="Fastparquet nullable dtype support is disabled" ) - request.node.add_marker(mark) + request.applymarker(mark) table = pyarrow.table( { @@ -988,7 +988,7 @@ def test_timezone_aware_index(self, request, pa, timezone_aware_date_list): not pa_version_under7p0 and timezone_aware_date_list.tzinfo != datetime.timezone.utc ): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="temporary skip this test until it is properly resolved: " "https://github.com/pandas-dev/pandas/issues/37286" diff --git a/pandas/tests/io/test_sql.py b/pandas/tests/io/test_sql.py index 11f95ff104767..63546b44e92be 100644 --- a/pandas/tests/io/test_sql.py +++ b/pandas/tests/io/test_sql.py @@ -817,7 +817,7 @@ def sample(pd_table, conn, keys, data_iter): def test_default_type_conversion(conn, request): conn_name = conn if conn_name == "sqlite_buildin_iris": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="sqlite_buildin connection does not implement read_sql_table" ) @@ -1155,7 +1155,7 @@ def test_read_sql_iris_named_parameter(conn, request, sql_strings, flavor): @pytest.mark.parametrize("conn", all_connectable_iris) def test_read_sql_iris_no_parameter_with_percent(conn, request, sql_strings, flavor): if "mysql" in conn or "postgresql" in conn: - request.node.add_marker(pytest.mark.xfail(reason="broken test")) + request.applymarker(pytest.mark.xfail(reason="broken test")) conn_name = conn conn = request.getfixturevalue(conn) @@ -1399,7 +1399,7 @@ def test_api_custom_dateparsing_error( conn_name = conn conn = request.getfixturevalue(conn) if text == "types" and conn_name == "sqlite_buildin_iris": - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason="failing combination of arguments") ) @@ -1497,7 +1497,7 @@ def test_api_to_sql_index_label(conn, request, index_name, index_label, expected def test_api_to_sql_index_label_multiindex(conn, request): conn_name = conn if "mysql" in conn_name: - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="MySQL can fail using TEXT without length as key", strict=False ) @@ -1802,7 +1802,7 @@ def test_read_table_columns(conn, request, test_frame1): # test columns argument in read_table conn_name = conn if conn_name == "sqlite_buildin": - request.node.add_marker(pytest.mark.xfail(reason="Not Implemented")) + request.applymarker(pytest.mark.xfail(reason="Not Implemented")) conn = request.getfixturevalue(conn) sql.to_sql(test_frame1, "test_frame", conn) @@ -1818,7 +1818,7 @@ def test_read_table_index_col(conn, request, test_frame1): # test columns argument in read_table conn_name = conn if conn_name == "sqlite_buildin": - request.node.add_marker(pytest.mark.xfail(reason="Not Implemented")) + request.applymarker(pytest.mark.xfail(reason="Not Implemented")) conn = request.getfixturevalue(conn) sql.to_sql(test_frame1, "test_frame", conn) @@ -1839,7 +1839,7 @@ def test_read_table_index_col(conn, request, test_frame1): @pytest.mark.parametrize("conn", all_connectable_iris) def test_read_sql_delegate(conn, request): if conn == "sqlite_buildin_iris": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="sqlite_buildin connection does not implement read_sql_table" ) @@ -1884,7 +1884,7 @@ def test_not_reflect_all_tables(sqlite_conn): def test_warning_case_insensitive_table_name(conn, request, test_frame1): conn_name = conn if conn_name == "sqlite_buildin": - request.node.add_marker(pytest.mark.xfail(reason="Does not raise warning")) + request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) conn = request.getfixturevalue(conn) # see gh-7815 @@ -2034,7 +2034,7 @@ def test_column_with_percentage(conn, request): # GH 37157 conn_name = conn if conn_name == "sqlite_buildin": - request.node.add_marker(pytest.mark.xfail(reason="Not Implemented")) + request.applymarker(pytest.mark.xfail(reason="Not Implemented")) conn = request.getfixturevalue(conn) df = DataFrame({"A": [0, 1, 2], "%_variation": [3, 4, 5]}) @@ -2226,7 +2226,7 @@ def test_sqlalchemy_default_type_conversion(conn, request): if conn_name == "sqlite_str": pytest.skip("types tables not created in sqlite_str fixture") elif "mysql" in conn_name or "sqlite" in conn_name: - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason="boolean dtype not inferred properly") ) @@ -2260,7 +2260,7 @@ def test_default_date_load(conn, request): if conn_name == "sqlite_str": pytest.skip("types tables not created in sqlite_str fixture") elif "sqlite" in conn_name: - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason="sqlite does not read date properly") ) @@ -2310,7 +2310,7 @@ def check(col): conn = request.getfixturevalue(conn) df = read_sql_query("select * from types", conn) if not hasattr(df, "DateColWithTz"): - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason="no column with datetime with time zone") ) @@ -2322,7 +2322,7 @@ def check(col): df = read_sql_query("select * from types", conn, parse_dates=["DateColWithTz"]) if not hasattr(df, "DateColWithTz"): - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason="no column with datetime with time zone") ) col = df.DateColWithTz @@ -2689,7 +2689,7 @@ def test_get_schema_create_table(conn, request, test_frame3): # TINYINT (which read_sql_table returns as an int and causes a dtype # mismatch) if conn == "sqlite_str": - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason="test does not support sqlite_str fixture") ) @@ -2901,7 +2901,7 @@ def test_to_sql_with_negative_npinf(conn, request, input): if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: mark = pytest.mark.xfail(reason="GH 36465") - request.node.add_marker(mark) + request.applymarker(mark) msg = "inf cannot be used with MySQL" with pytest.raises(ValueError, match=msg): @@ -2953,7 +2953,7 @@ class Temporary(Base): @pytest.mark.parametrize("conn", all_connectable) def test_invalid_engine(conn, request, test_frame1): if conn == "sqlite_buildin": - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason="SQLiteDatabase does not raise for bad engine") ) @@ -3078,7 +3078,7 @@ def test_read_sql_dtype_backend_table( dtype_backend_expected, ): if "sqlite" in conn: - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=( "SQLite actually returns proper boolean values via " diff --git a/pandas/tests/reshape/concat/test_append_common.py b/pandas/tests/reshape/concat/test_append_common.py index df5ca2f27c15d..a87042180df8f 100644 --- a/pandas/tests/reshape/concat/test_append_common.py +++ b/pandas/tests/reshape/concat/test_append_common.py @@ -197,11 +197,11 @@ def test_concatlike_dtypes_coercion(self, item, item2, request): # index doesn't because bool is object dtype exp_series_dtype = typ2 mark = pytest.mark.xfail(reason="GH#39187 casting to object") - request.node.add_marker(mark) + request.applymarker(mark) elif typ2 == "bool" and typ1 in ("int64", "float64"): exp_series_dtype = typ1 mark = pytest.mark.xfail(reason="GH#39187 casting to object") - request.node.add_marker(mark) + request.applymarker(mark) elif typ1 in {"datetime64[ns, US/Eastern]", "timedelta64[ns]"} or typ2 in { "datetime64[ns, US/Eastern]", "timedelta64[ns]", diff --git a/pandas/tests/scalar/timestamp/test_constructors.py b/pandas/tests/scalar/timestamp/test_constructors.py index b65b34f748260..5eddb4b83f44c 100644 --- a/pandas/tests/scalar/timestamp/test_constructors.py +++ b/pandas/tests/scalar/timestamp/test_constructors.py @@ -353,7 +353,7 @@ def test_constructor_positional_keyword_mixed_with_tzinfo(self, kwd, request): if kwd != "nanosecond": # nanosecond is keyword-only as of 2.0, others are not mark = pytest.mark.xfail(reason="GH#45307") - request.node.add_marker(mark) + request.applymarker(mark) kwargs = {kwd: 4} ts = Timestamp(2020, 12, 31, tzinfo=timezone.utc, **kwargs) diff --git a/pandas/tests/series/methods/test_astype.py b/pandas/tests/series/methods/test_astype.py index 03fc6cba2902a..faa3978038dd5 100644 --- a/pandas/tests/series/methods/test_astype.py +++ b/pandas/tests/series/methods/test_astype.py @@ -170,7 +170,7 @@ def test_astype_generic_timestamp_no_frequency(self, dtype, request): if np.dtype(dtype).name not in ["timedelta64", "datetime64"]: mark = pytest.mark.xfail(reason="GH#33890 Is assigned ns unit") - request.node.add_marker(mark) + request.applymarker(mark) msg = ( rf"The '{dtype.__name__}' dtype has no unit\. " @@ -485,7 +485,7 @@ def test_astype_string_to_extension_dtype_roundtrip( mark = pytest.mark.xfail( reason="TODO StringArray.astype() with missing values #GH40566" ) - request.node.add_marker(mark) + request.applymarker(mark) # GH-40351 ser = Series(data, dtype=dtype) diff --git a/pandas/tests/series/methods/test_interpolate.py b/pandas/tests/series/methods/test_interpolate.py index f8bbd4c25a4c0..426885bf41a1f 100644 --- a/pandas/tests/series/methods/test_interpolate.py +++ b/pandas/tests/series/methods/test_interpolate.py @@ -831,7 +831,7 @@ def test_interpolate_timedelta_index(self, request, interp_methods_ind): method, kwargs = interp_methods_ind if method in {"cubic", "zero"}: - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=f"{method} interpolation is not supported for TimedeltaIndex" ) diff --git a/pandas/tests/series/methods/test_map.py b/pandas/tests/series/methods/test_map.py index ae6c62e95f696..6b357281c831b 100644 --- a/pandas/tests/series/methods/test_map.py +++ b/pandas/tests/series/methods/test_map.py @@ -204,7 +204,7 @@ def test_map(datetime_series): def test_map_empty(request, index): if isinstance(index, MultiIndex): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason="Initializing a Series from a MultiIndex is not supported" ) diff --git a/pandas/tests/series/test_arithmetic.py b/pandas/tests/series/test_arithmetic.py index e9eb906a9cf10..656f6736f03ee 100644 --- a/pandas/tests/series/test_arithmetic.py +++ b/pandas/tests/series/test_arithmetic.py @@ -881,7 +881,7 @@ def test_none_comparison(request, series_with_simple_index): series = series_with_simple_index if len(series) < 1: - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason="Test doesn't make sense on empty data") ) diff --git a/pandas/tests/series/test_constructors.py b/pandas/tests/series/test_constructors.py index 4f9050be100ca..dc5158cb5813c 100644 --- a/pandas/tests/series/test_constructors.py +++ b/pandas/tests/series/test_constructors.py @@ -1362,7 +1362,7 @@ def test_constructor_dict_extension(self, ea_scalar_and_dtype, request): reason="Construction from dict goes through " "maybe_convert_objects which casts to nano" ) - request.node.add_marker(mark) + request.applymarker(mark) d = {"a": ea_scalar} result = Series(d, index=["a"]) expected = Series(ea_scalar, index=["a"], dtype=ea_dtype) @@ -1688,7 +1688,7 @@ def test_constructor_generic_timestamp_no_frequency(self, dtype, request): if np.dtype(dtype).name not in ["timedelta64", "datetime64"]: mark = pytest.mark.xfail(reason="GH#33890 Is assigned ns unit") - request.node.add_marker(mark) + request.applymarker(mark) with pytest.raises(ValueError, match=msg): Series([], dtype=dtype) diff --git a/pandas/tests/series/test_ufunc.py b/pandas/tests/series/test_ufunc.py index 698c727f1beb8..a75e77a5e2714 100644 --- a/pandas/tests/series/test_ufunc.py +++ b/pandas/tests/series/test_ufunc.py @@ -274,7 +274,7 @@ def test_multiply(self, values_for_np_reduce, box_with_array, request): if isinstance(values, pd.core.arrays.SparseArray): mark = pytest.mark.xfail(reason="SparseArray has no 'prod'") - request.node.add_marker(mark) + request.applymarker(mark) if values.dtype.kind in "iuf": result = np.multiply.reduce(obj) diff --git a/pandas/tests/strings/test_api.py b/pandas/tests/strings/test_api.py index c439a5f006922..0d2f220e70c56 100644 --- a/pandas/tests/strings/test_api.py +++ b/pandas/tests/strings/test_api.py @@ -92,7 +92,7 @@ def test_api_per_method( if reason is not None: mark = pytest.mark.xfail(raises=raises, reason=reason) - request.node.add_marker(mark) + request.applymarker(mark) t = box(values, dtype=dtype) # explicit dtype to avoid casting method = getattr(t.str, method_name) diff --git a/pandas/tests/tools/test_to_datetime.py b/pandas/tests/tools/test_to_datetime.py index b0406dbfa3469..aefaba1aed058 100644 --- a/pandas/tests/tools/test_to_datetime.py +++ b/pandas/tests/tools/test_to_datetime.py @@ -1831,7 +1831,7 @@ def test_to_datetime_month_or_year_unit_int(self, cache, unit, item, request): # TODO: this should also work if isinstance(item, float): - request.node.add_marker( + request.applymarker( pytest.mark.xfail( reason=f"{type(item).__name__} in np.array should work" ) diff --git a/pandas/tests/tools/test_to_numeric.py b/pandas/tests/tools/test_to_numeric.py index 1d969e648b752..da8e2fe9abc16 100644 --- a/pandas/tests/tools/test_to_numeric.py +++ b/pandas/tests/tools/test_to_numeric.py @@ -396,7 +396,7 @@ def test_period(request, transform_assert_equal): inp = transform(idx) if not isinstance(inp, Index): - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason="Missing PeriodDtype support in to_numeric") ) result = to_numeric(inp) diff --git a/pandas/tests/tseries/offsets/test_common.py b/pandas/tests/tseries/offsets/test_common.py index 1b90b94d8a9da..5b80b8b1c4ab4 100644 --- a/pandas/tests/tseries/offsets/test_common.py +++ b/pandas/tests/tseries/offsets/test_common.py @@ -142,7 +142,7 @@ def test_apply_out_of_range(request, tz_naive_fixture, _offset): if isinstance(tz, tzlocal) and not IS64 and _offset is not DateOffset: # If we hit OutOfBoundsDatetime on non-64 bit machines # we'll drop out of the try clause before the next test - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason="OverflowError inside tzlocal past 2038") ) elif ( @@ -150,7 +150,7 @@ def test_apply_out_of_range(request, tz_naive_fixture, _offset): and is_platform_windows() and _offset in (QuarterEnd, BQuarterBegin, BQuarterEnd) ): - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason="After GH#49737 t.tzinfo is None on CI") ) assert str(t.tzinfo) == str(result.tzinfo) diff --git a/pandas/tests/tseries/offsets/test_offsets.py b/pandas/tests/tseries/offsets/test_offsets.py index 5678dd1fb511e..7cefd93851b0e 100644 --- a/pandas/tests/tseries/offsets/test_offsets.py +++ b/pandas/tests/tseries/offsets/test_offsets.py @@ -602,7 +602,7 @@ def test_mul(self): @pytest.mark.parametrize("kwd", sorted(liboffsets._relativedelta_kwds)) def test_constructor(self, kwd, request): if kwd == "millisecond": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( raises=NotImplementedError, reason="Constructing DateOffset object with `millisecond` is not " @@ -916,7 +916,7 @@ def test_month_offset_name(month_classes): @pytest.mark.parametrize("kwd", sorted(liboffsets._relativedelta_kwds)) def test_valid_relativedelta_kwargs(kwd, request): if kwd == "millisecond": - request.node.add_marker( + request.applymarker( pytest.mark.xfail( raises=NotImplementedError, reason="Constructing DateOffset object with `millisecond` is not " diff --git a/pandas/tests/window/moments/test_moments_consistency_expanding.py b/pandas/tests/window/moments/test_moments_consistency_expanding.py index dafc60a057c0f..7d2fa1ad5d211 100644 --- a/pandas/tests/window/moments/test_moments_consistency_expanding.py +++ b/pandas/tests/window/moments/test_moments_consistency_expanding.py @@ -19,7 +19,7 @@ def test_expanding_apply_consistency_sum_nans(request, all_data, min_periods, f) if not no_nans(all_data) and not ( all_na(all_data) and not all_data.empty and min_periods > 0 ): - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason="np.sum has different behavior with NaNs") ) expanding_f_result = all_data.expanding(min_periods=min_periods).sum() diff --git a/pandas/tests/window/moments/test_moments_consistency_rolling.py b/pandas/tests/window/moments/test_moments_consistency_rolling.py index 62bfc66b124f3..be22338c00cb2 100644 --- a/pandas/tests/window/moments/test_moments_consistency_rolling.py +++ b/pandas/tests/window/moments/test_moments_consistency_rolling.py @@ -29,7 +29,7 @@ def test_rolling_apply_consistency_sum( if not no_nans(all_data) and not ( all_na(all_data) and not all_data.empty and min_periods > 0 ): - request.node.add_marker( + request.applymarker( pytest.mark.xfail(reason="np.sum has different behavior with NaNs") ) rolling_f_result = all_data.rolling( diff --git a/pandas/util/_test_decorators.py b/pandas/util/_test_decorators.py index 9be0c3edaa998..3292b701c18d7 100644 --- a/pandas/util/_test_decorators.py +++ b/pandas/util/_test_decorators.py @@ -229,7 +229,7 @@ def async_mark(): def mark_array_manager_not_yet_implemented(request) -> None: mark = pytest.mark.xfail(reason="Not yet implemented for ArrayManager") - request.node.add_marker(mark) + request.applymarker(mark) skip_array_manager_not_yet_implemented = pytest.mark.xfail(