Skip to content

Commit

Permalink
TST: Replace node.add_marker with applymarker (pandas-dev#55513)
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke authored Oct 15, 2023
1 parent 7b8c6f6 commit e0d6051
Show file tree
Hide file tree
Showing 74 changed files with 216 additions and 242 deletions.
2 changes: 1 addition & 1 deletion doc/source/development/contributing_codebase.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/apply/test_frame_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/apply/test_frame_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)

Expand Down Expand Up @@ -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")
)

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/apply/test_series_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)

Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/apply/test_str.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down Expand Up @@ -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 []
Expand All @@ -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")
)

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/arithmetic/test_datetime64.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)

Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/arrays/string_/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <class 'ValueError'>"
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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/base/test_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/base/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/computation/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)"

Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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}",
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/copy_view/test_core_functionalities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))


Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/extension/decimal/test_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/extension/json/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -300,15 +300,15 @@ 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)


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)


Expand Down
Loading

0 comments on commit e0d6051

Please sign in to comment.