Skip to content

TST: skip->xfail #44647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions pandas/tests/arrays/masked/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ def test_array_scalar_like_equivalence(data, all_arithmetic_operators):
tm.assert_extension_array_equal(result, expected)


def test_array_NA(data, all_arithmetic_operators):
if "truediv" in all_arithmetic_operators:
pytest.skip("division with pd.NA raises")
def test_array_NA(data, all_arithmetic_operators, request):
if "truediv" in all_arithmetic_operators and data[0].dtype.kind != "f":
mark = pytest.mark.xfail(reason="division with pd.NA fails")
request.node.add_marker(mark)

data, _ = data
op = tm.get_op_from_name(all_arithmetic_operators)
check_skip(data, all_arithmetic_operators)
Expand Down
9 changes: 4 additions & 5 deletions pandas/tests/base/test_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,12 @@ def test_numpy_array_all_dtypes(any_numpy_dtype):
),
],
)
def test_array(arr, attr, index_or_series):
def test_array(arr, attr, index_or_series, request):
box = index_or_series
if arr.dtype.name in ("Int64", "Sparse[int64, 0]") and box is pd.Index:
pytest.skip(f"No index type for {arr.dtype}")
mark = pytest.mark.xfail(reason="Needs EA-Backed Index")
request.node.add_marker(mark)

result = box(arr, copy=False).array

if attr:
Expand Down Expand Up @@ -341,9 +343,6 @@ def test_to_numpy(arr, expected, index_or_series_or_array, request):
box = index_or_series_or_array
thing = box(arr)

if arr.dtype.name in ("Int64", "Sparse[int64, 0]") and box is pd.Index:
pytest.skip(f"No index type for {arr.dtype}")

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)
Expand Down
11 changes: 5 additions & 6 deletions pandas/tests/base/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import pandas as pd
from pandas import (
DataFrame,
Index,
Series,
)
Expand All @@ -33,10 +32,11 @@
("floordiv", "//"),
],
)
@pytest.mark.parametrize("klass", [Series, DataFrame])
def test_binary_ops_docstring(klass, op_name, op):
def test_binary_ops_docstring(frame_or_series, op_name, op):
# not using the all_arithmetic_functions fixture with _get_opstr
# as _get_opstr is used internally in the dynamic implementation of the docstring
klass = frame_or_series

operand1 = klass.__name__.lower()
operand2 = "other"
expected_str = " ".join([operand1, op, operand2])
Expand Down Expand Up @@ -134,12 +134,11 @@ def test_searchsorted(index_or_series_obj):
assert 0 <= index <= len(obj)


def test_access_by_position(index):
def test_access_by_position(index_flat):
index = index_flat

if len(index) == 0:
pytest.skip("Test doesn't make sense on empty data")
elif isinstance(index, pd.MultiIndex):
pytest.skip("Can't instantiate Series from MultiIndex")

series = Series(index)
assert index[0] == series.iloc[0]
Expand Down
7 changes: 1 addition & 6 deletions pandas/tests/extension/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,7 @@ def test_combine_add(self, data_repeated):


class TestInterface(BaseDatetimeTests, base.BaseInterfaceTests):
def test_array_interface(self, data):
if data.tz:
# np.asarray(DTA) is currently always tz-naive.
pytest.skip("GH-23569")
else:
super().test_array_interface(data)
pass


class TestArithmeticOps(BaseDatetimeTests, base.BaseArithmeticOpsTests):
Expand Down
11 changes: 5 additions & 6 deletions pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,14 +822,13 @@ def test_isin_nan_common_float64(self, request, nulls_fixture):
pytest.mark.xfail(reason="Float64Index cannot contain pd.NA")
)

tm.assert_numpy_array_equal(
Float64Index([1.0, nulls_fixture]).isin([np.nan]), np.array([False, True])
)
idx = Float64Index([1.0, nulls_fixture])
res = idx.isin([np.nan])
tm.assert_numpy_array_equal(res, np.array([False, True]))

# we cannot compare NaT with NaN
tm.assert_numpy_array_equal(
Float64Index([1.0, nulls_fixture]).isin([pd.NaT]), np.array([False, False])
)
res = idx.isin([pd.NaT])
tm.assert_numpy_array_equal(res, np.array([False, False]))

@pytest.mark.parametrize("level", [0, -1])
@pytest.mark.parametrize(
Expand Down
12 changes: 8 additions & 4 deletions pandas/tests/indexing/test_coercion.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,10 +610,12 @@ def test_where_object(self, index_or_series, fill_val, exp_dtype):
"fill_val,exp_dtype",
[(1, np.int64), (1.1, np.float64), (1 + 1j, np.complex128), (True, object)],
)
def test_where_int64(self, index_or_series, fill_val, exp_dtype):
def test_where_int64(self, index_or_series, fill_val, exp_dtype, request):
klass = index_or_series
if klass is pd.Index and exp_dtype is np.complex128:
pytest.skip("Complex Index not supported")
mark = pytest.mark.xfail(reason="Complex Index not supported")
request.node.add_marker(mark)

obj = klass([1, 2, 3, 4])
assert obj.dtype == np.int64
cond = klass([True, False, True, False])
Expand All @@ -632,10 +634,12 @@ def test_where_int64(self, index_or_series, fill_val, exp_dtype):
"fill_val, exp_dtype",
[(1, np.float64), (1.1, np.float64), (1 + 1j, np.complex128), (True, object)],
)
def test_where_float64(self, index_or_series, fill_val, exp_dtype):
def test_where_float64(self, index_or_series, fill_val, exp_dtype, request):
klass = index_or_series
if klass is pd.Index and exp_dtype is np.complex128:
pytest.skip("Complex Index not supported")
mark = pytest.mark.xfail(reason="Complex Index not supported")
request.node.add_marker(mark)

obj = klass([1.1, 2.2, 3.3, 4.4])
assert obj.dtype == np.float64
cond = klass([True, False, True, False])
Expand Down
5 changes: 3 additions & 2 deletions pandas/tests/io/parser/test_skiprows.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def test_skip_row_with_newline_and_quote(all_parsers, data, exp_data):
@pytest.mark.parametrize(
"line_terminator", ["\n", "\r\n", "\r"] # "LF" # "CRLF" # "CR"
)
def test_skiprows_lineterminator(all_parsers, line_terminator):
def test_skiprows_lineterminator(all_parsers, line_terminator, request):
# see gh-9079
parser = all_parsers
data = "\n".join(
Expand All @@ -203,7 +203,8 @@ def test_skiprows_lineterminator(all_parsers, line_terminator):
)

if parser.engine == "python" and line_terminator == "\r":
pytest.skip("'CR' not respect with the Python parser yet")
mark = pytest.mark.xfail(reason="'CR' not respect with the Python parser yet")
request.node.add_marker(mark)

data = data.replace("\n", line_terminator)
result = parser.read_csv(
Expand Down
6 changes: 5 additions & 1 deletion pandas/tests/io/pytables/test_round_trip.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import pytest

from pandas._libs.tslibs import Timestamp
from pandas.compat import is_platform_windows

import pandas as pd
from pandas import (
Expand Down Expand Up @@ -350,7 +351,10 @@ def test_timeseries_preepoch(setup_path):
try:
_check_roundtrip(ts, tm.assert_series_equal, path=setup_path)
except OverflowError:
pytest.skip("known failure on some windows platforms")
if is_platform_windows():
pytest.xfail("known failure on some windows platforms")
else:
raise


@pytest.mark.parametrize(
Expand Down
7 changes: 4 additions & 3 deletions pandas/tests/reductions/test_reductions.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,18 @@ def test_ops(self, opname, obj):
("boolean", True),
],
)
def test_nanminmax(self, opname, dtype, val, index_or_series):
def test_nanminmax(self, opname, dtype, val, index_or_series, request):
# GH#7261
klass = index_or_series

if dtype in ["Int64", "boolean"] and klass == Index:
pytest.skip("EAs can't yet be stored in an index")
mark = pytest.mark.xfail(reason="Need EA-backed Index")
request.node.add_marker(mark)

def check_missing(res):
if dtype == "datetime64[ns]":
return res is NaT
elif dtype == "Int64":
elif dtype in ["Int64", "boolean"]:
return res is pd.NA
else:
return isna(res)
Expand Down
2 changes: 2 additions & 0 deletions pandas/tests/series/indexing/test_setitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ def test_series_where(self, obj, key, expected, val, is_inplace):

def test_index_where(self, obj, key, expected, val, request):
if Index(obj).dtype != obj.dtype:
# TODO(ExtensionIndex): Should become unreachable
pytest.skip("test not applicable for this dtype")

mask = np.zeros(obj.shape, dtype=bool)
Expand All @@ -667,6 +668,7 @@ def test_index_where(self, obj, key, expected, val, request):

def test_index_putmask(self, obj, key, expected, val):
if Index(obj).dtype != obj.dtype:
# TODO(ExtensionIndex): Should become unreachable
pytest.skip("test not applicable for this dtype")

mask = np.zeros(obj.shape, dtype=bool)
Expand Down
37 changes: 20 additions & 17 deletions pandas/tests/series/methods/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@

class TestSeriesDiff:
def test_diff_np(self):
pytest.skip("skipping due to Series no longer being an ndarray")
# TODO(__array_function__): could make np.diff return a Series
# matching ser.diff()

# no longer works as the return type of np.diff is now nd.array
s = Series(np.arange(5))
ser = Series(np.arange(5))

r = np.diff(s)
tm.assert_series_equal(Series([np.nan, 0, 0, 0, np.nan]), r)
res = np.diff(ser)
expected = np.array([1, 1, 1, 1])
tm.assert_numpy_array_equal(res, expected)

def test_diff_int(self):
# int dtype
a = 10000000000000000
b = a + 1
s = Series([a, b])
ser = Series([a, b])

result = s.diff()
result = ser.diff()
assert result[1] == 1

def test_diff_tz(self):
Expand All @@ -43,22 +44,24 @@ def test_diff_tz(self):
expected = ts - ts
tm.assert_series_equal(result, expected)

def test_diff_dt64(self):
# datetime diff (GH#3100)
s = Series(date_range("20130102", periods=5))
result = s.diff()
expected = s - s.shift(1)
ser = Series(date_range("20130102", periods=5))
result = ser.diff()
expected = ser - ser.shift(1)
tm.assert_series_equal(result, expected)

# timedelta diff
result = result - result.shift(1) # previous result
expected = expected.diff() # previously expected
tm.assert_series_equal(result, expected)

def test_diff_dt64tz(self):
# with tz
s = Series(
ser = Series(
date_range("2000-01-01 09:00:00", periods=5, tz="US/Eastern"), name="foo"
)
result = s.diff()
result = ser.diff()
expected = Series(TimedeltaIndex(["NaT"] + ["1 days"] * 4), name="foo")
tm.assert_series_equal(result, expected)

Expand All @@ -68,14 +71,14 @@ def test_diff_tz(self):
)
def test_diff_bool(self, input, output, diff):
# boolean series (test for fixing #17294)
s = Series(input)
result = s.diff()
ser = Series(input)
result = ser.diff()
expected = Series(output)
tm.assert_series_equal(result, expected)

def test_diff_object_dtype(self):
# object series
s = Series([False, True, 5.0, np.nan, True, False])
result = s.diff()
expected = s - s.shift(1)
ser = Series([False, True, 5.0, np.nan, True, False])
result = ser.diff()
expected = ser - ser.shift(1)
tm.assert_series_equal(result, expected)
7 changes: 5 additions & 2 deletions pandas/tests/series/test_ufunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,15 @@ def test_binary_ufunc_scalar(ufunc, sparse, flip, arrays_for_binary_ufunc):
@pytest.mark.parametrize("sparse", SPARSE, ids=SPARSE_IDS)
@pytest.mark.parametrize("shuffle", SHUFFLE)
@pytest.mark.filterwarnings("ignore:divide by zero:RuntimeWarning")
def test_multiple_output_binary_ufuncs(ufunc, sparse, shuffle, arrays_for_binary_ufunc):
def test_multiple_output_binary_ufuncs(
ufunc, sparse, shuffle, arrays_for_binary_ufunc, request
):
# Test that
# the same conditions from binary_ufunc_scalar apply to
# ufuncs with multiple outputs.
if sparse and ufunc is np.divmod:
pytest.skip("sparse divmod not implemented.")
mark = pytest.mark.xfail(reason="sparse divmod not implemented")
request.node.add_marker(mark)

a1, a2 = arrays_for_binary_ufunc
# work around https://github.com/pandas-dev/pandas/issues/26987
Expand Down
7 changes: 5 additions & 2 deletions pandas/tests/strings/test_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,12 @@ def test_len_mixed():
("rindex", "E", 0, 5, [4, 3, 1, 4]),
],
)
def test_index(method, sub, start, end, index_or_series, any_string_dtype, expected):
def test_index(
method, sub, start, end, index_or_series, any_string_dtype, expected, request
):
if index_or_series is Index and not any_string_dtype == "object":
pytest.skip("Index cannot yet be backed by a StringArray/ArrowStringArray")
mark = pytest.mark.xfail(reason="Need EA-backed Index")
request.node.add_marker(mark)

obj = index_or_series(
["ABCDEFG", "BCDEFEF", "DEFGHIJEF", "EFGHEF"], dtype=any_string_dtype
Expand Down