Skip to content

Commit be83376

Browse files
authored
TST: skip->xfail (#44647)
1 parent 035501e commit be83376

File tree

13 files changed

+72
-57
lines changed

13 files changed

+72
-57
lines changed

pandas/tests/arrays/masked/test_arithmetic.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ def test_array_scalar_like_equivalence(data, all_arithmetic_operators):
4848
tm.assert_extension_array_equal(result, expected)
4949

5050

51-
def test_array_NA(data, all_arithmetic_operators):
52-
if "truediv" in all_arithmetic_operators:
53-
pytest.skip("division with pd.NA raises")
51+
def test_array_NA(data, all_arithmetic_operators, request):
52+
if "truediv" in all_arithmetic_operators and data[0].dtype.kind != "f":
53+
mark = pytest.mark.xfail(reason="division with pd.NA fails")
54+
request.node.add_marker(mark)
55+
5456
data, _ = data
5557
op = tm.get_op_from_name(all_arithmetic_operators)
5658
check_skip(data, all_arithmetic_operators)

pandas/tests/base/test_conversion.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,12 @@ def test_numpy_array_all_dtypes(any_numpy_dtype):
265265
),
266266
],
267267
)
268-
def test_array(arr, attr, index_or_series):
268+
def test_array(arr, attr, index_or_series, request):
269269
box = index_or_series
270270
if arr.dtype.name in ("Int64", "Sparse[int64, 0]") and box is pd.Index:
271-
pytest.skip(f"No index type for {arr.dtype}")
271+
mark = pytest.mark.xfail(reason="Needs EA-Backed Index")
272+
request.node.add_marker(mark)
273+
272274
result = box(arr, copy=False).array
273275

274276
if attr:
@@ -341,9 +343,6 @@ def test_to_numpy(arr, expected, index_or_series_or_array, request):
341343
box = index_or_series_or_array
342344
thing = box(arr)
343345

344-
if arr.dtype.name in ("Int64", "Sparse[int64, 0]") and box is pd.Index:
345-
pytest.skip(f"No index type for {arr.dtype}")
346-
347346
if arr.dtype.name == "int64" and box is pd.array:
348347
mark = pytest.mark.xfail(reason="thing is Int64 and to_numpy() returns object")
349348
request.node.add_marker(mark)

pandas/tests/base/test_misc.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
import pandas as pd
1717
from pandas import (
18-
DataFrame,
1918
Index,
2019
Series,
2120
)
@@ -33,10 +32,11 @@
3332
("floordiv", "//"),
3433
],
3534
)
36-
@pytest.mark.parametrize("klass", [Series, DataFrame])
37-
def test_binary_ops_docstring(klass, op_name, op):
35+
def test_binary_ops_docstring(frame_or_series, op_name, op):
3836
# not using the all_arithmetic_functions fixture with _get_opstr
3937
# as _get_opstr is used internally in the dynamic implementation of the docstring
38+
klass = frame_or_series
39+
4040
operand1 = klass.__name__.lower()
4141
operand2 = "other"
4242
expected_str = " ".join([operand1, op, operand2])
@@ -134,12 +134,11 @@ def test_searchsorted(index_or_series_obj):
134134
assert 0 <= index <= len(obj)
135135

136136

137-
def test_access_by_position(index):
137+
def test_access_by_position(index_flat):
138+
index = index_flat
138139

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

144143
series = Series(index)
145144
assert index[0] == series.iloc[0]

pandas/tests/extension/test_datetime.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,7 @@ def test_combine_add(self, data_repeated):
114114

115115

116116
class TestInterface(BaseDatetimeTests, base.BaseInterfaceTests):
117-
def test_array_interface(self, data):
118-
if data.tz:
119-
# np.asarray(DTA) is currently always tz-naive.
120-
pytest.skip("GH-23569")
121-
else:
122-
super().test_array_interface(data)
117+
pass
123118

124119

125120
class TestArithmeticOps(BaseDatetimeTests, base.BaseArithmeticOpsTests):

pandas/tests/indexes/test_base.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -822,14 +822,13 @@ def test_isin_nan_common_float64(self, request, nulls_fixture):
822822
pytest.mark.xfail(reason="Float64Index cannot contain pd.NA")
823823
)
824824

825-
tm.assert_numpy_array_equal(
826-
Float64Index([1.0, nulls_fixture]).isin([np.nan]), np.array([False, True])
827-
)
825+
idx = Float64Index([1.0, nulls_fixture])
826+
res = idx.isin([np.nan])
827+
tm.assert_numpy_array_equal(res, np.array([False, True]))
828828

829829
# we cannot compare NaT with NaN
830-
tm.assert_numpy_array_equal(
831-
Float64Index([1.0, nulls_fixture]).isin([pd.NaT]), np.array([False, False])
832-
)
830+
res = idx.isin([pd.NaT])
831+
tm.assert_numpy_array_equal(res, np.array([False, False]))
833832

834833
@pytest.mark.parametrize("level", [0, -1])
835834
@pytest.mark.parametrize(

pandas/tests/indexing/test_coercion.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -610,10 +610,12 @@ def test_where_object(self, index_or_series, fill_val, exp_dtype):
610610
"fill_val,exp_dtype",
611611
[(1, np.int64), (1.1, np.float64), (1 + 1j, np.complex128), (True, object)],
612612
)
613-
def test_where_int64(self, index_or_series, fill_val, exp_dtype):
613+
def test_where_int64(self, index_or_series, fill_val, exp_dtype, request):
614614
klass = index_or_series
615615
if klass is pd.Index and exp_dtype is np.complex128:
616-
pytest.skip("Complex Index not supported")
616+
mark = pytest.mark.xfail(reason="Complex Index not supported")
617+
request.node.add_marker(mark)
618+
617619
obj = klass([1, 2, 3, 4])
618620
assert obj.dtype == np.int64
619621
cond = klass([True, False, True, False])
@@ -632,10 +634,12 @@ def test_where_int64(self, index_or_series, fill_val, exp_dtype):
632634
"fill_val, exp_dtype",
633635
[(1, np.float64), (1.1, np.float64), (1 + 1j, np.complex128), (True, object)],
634636
)
635-
def test_where_float64(self, index_or_series, fill_val, exp_dtype):
637+
def test_where_float64(self, index_or_series, fill_val, exp_dtype, request):
636638
klass = index_or_series
637639
if klass is pd.Index and exp_dtype is np.complex128:
638-
pytest.skip("Complex Index not supported")
640+
mark = pytest.mark.xfail(reason="Complex Index not supported")
641+
request.node.add_marker(mark)
642+
639643
obj = klass([1.1, 2.2, 3.3, 4.4])
640644
assert obj.dtype == np.float64
641645
cond = klass([True, False, True, False])

pandas/tests/io/parser/test_skiprows.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def test_skip_row_with_newline_and_quote(all_parsers, data, exp_data):
182182
@pytest.mark.parametrize(
183183
"line_terminator", ["\n", "\r\n", "\r"] # "LF" # "CRLF" # "CR"
184184
)
185-
def test_skiprows_lineterminator(all_parsers, line_terminator):
185+
def test_skiprows_lineterminator(all_parsers, line_terminator, request):
186186
# see gh-9079
187187
parser = all_parsers
188188
data = "\n".join(
@@ -203,7 +203,8 @@ def test_skiprows_lineterminator(all_parsers, line_terminator):
203203
)
204204

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

208209
data = data.replace("\n", line_terminator)
209210
result = parser.read_csv(

pandas/tests/io/pytables/test_round_trip.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import pytest
1010

1111
from pandas._libs.tslibs import Timestamp
12+
from pandas.compat import is_platform_windows
1213

1314
import pandas as pd
1415
from pandas import (
@@ -350,7 +351,10 @@ def test_timeseries_preepoch(setup_path):
350351
try:
351352
_check_roundtrip(ts, tm.assert_series_equal, path=setup_path)
352353
except OverflowError:
353-
pytest.skip("known failure on some windows platforms")
354+
if is_platform_windows():
355+
pytest.xfail("known failure on some windows platforms")
356+
else:
357+
raise
354358

355359

356360
@pytest.mark.parametrize(

pandas/tests/reductions/test_reductions.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,18 @@ def test_ops(self, opname, obj):
7979
("boolean", True),
8080
],
8181
)
82-
def test_nanminmax(self, opname, dtype, val, index_or_series):
82+
def test_nanminmax(self, opname, dtype, val, index_or_series, request):
8383
# GH#7261
8484
klass = index_or_series
8585

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

8990
def check_missing(res):
9091
if dtype == "datetime64[ns]":
9192
return res is NaT
92-
elif dtype == "Int64":
93+
elif dtype in ["Int64", "boolean"]:
9394
return res is pd.NA
9495
else:
9596
return isna(res)

pandas/tests/series/indexing/test_setitem.py

+2
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ def test_series_where(self, obj, key, expected, val, is_inplace):
652652

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

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

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

672674
mask = np.zeros(obj.shape, dtype=bool)

pandas/tests/series/methods/test_diff.py

+20-17
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,22 @@
1111

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

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

19-
r = np.diff(s)
20-
tm.assert_series_equal(Series([np.nan, 0, 0, 0, np.nan]), r)
19+
res = np.diff(ser)
20+
expected = np.array([1, 1, 1, 1])
21+
tm.assert_numpy_array_equal(res, expected)
2122

2223
def test_diff_int(self):
2324
# int dtype
2425
a = 10000000000000000
2526
b = a + 1
26-
s = Series([a, b])
27+
ser = Series([a, b])
2728

28-
result = s.diff()
29+
result = ser.diff()
2930
assert result[1] == 1
3031

3132
def test_diff_tz(self):
@@ -43,22 +44,24 @@ def test_diff_tz(self):
4344
expected = ts - ts
4445
tm.assert_series_equal(result, expected)
4546

47+
def test_diff_dt64(self):
4648
# datetime diff (GH#3100)
47-
s = Series(date_range("20130102", periods=5))
48-
result = s.diff()
49-
expected = s - s.shift(1)
49+
ser = Series(date_range("20130102", periods=5))
50+
result = ser.diff()
51+
expected = ser - ser.shift(1)
5052
tm.assert_series_equal(result, expected)
5153

5254
# timedelta diff
5355
result = result - result.shift(1) # previous result
5456
expected = expected.diff() # previously expected
5557
tm.assert_series_equal(result, expected)
5658

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

@@ -68,14 +71,14 @@ def test_diff_tz(self):
6871
)
6972
def test_diff_bool(self, input, output, diff):
7073
# boolean series (test for fixing #17294)
71-
s = Series(input)
72-
result = s.diff()
74+
ser = Series(input)
75+
result = ser.diff()
7376
expected = Series(output)
7477
tm.assert_series_equal(result, expected)
7578

7679
def test_diff_object_dtype(self):
7780
# object series
78-
s = Series([False, True, 5.0, np.nan, True, False])
79-
result = s.diff()
80-
expected = s - s.shift(1)
81+
ser = Series([False, True, 5.0, np.nan, True, False])
82+
result = ser.diff()
83+
expected = ser - ser.shift(1)
8184
tm.assert_series_equal(result, expected)

pandas/tests/series/test_ufunc.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,15 @@ def test_binary_ufunc_scalar(ufunc, sparse, flip, arrays_for_binary_ufunc):
171171
@pytest.mark.parametrize("sparse", SPARSE, ids=SPARSE_IDS)
172172
@pytest.mark.parametrize("shuffle", SHUFFLE)
173173
@pytest.mark.filterwarnings("ignore:divide by zero:RuntimeWarning")
174-
def test_multiple_output_binary_ufuncs(ufunc, sparse, shuffle, arrays_for_binary_ufunc):
174+
def test_multiple_output_binary_ufuncs(
175+
ufunc, sparse, shuffle, arrays_for_binary_ufunc, request
176+
):
175177
# Test that
176178
# the same conditions from binary_ufunc_scalar apply to
177179
# ufuncs with multiple outputs.
178180
if sparse and ufunc is np.divmod:
179-
pytest.skip("sparse divmod not implemented.")
181+
mark = pytest.mark.xfail(reason="sparse divmod not implemented")
182+
request.node.add_marker(mark)
180183

181184
a1, a2 = arrays_for_binary_ufunc
182185
# work around https://github.com/pandas-dev/pandas/issues/26987

pandas/tests/strings/test_strings.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,12 @@ def test_len_mixed():
364364
("rindex", "E", 0, 5, [4, 3, 1, 4]),
365365
],
366366
)
367-
def test_index(method, sub, start, end, index_or_series, any_string_dtype, expected):
367+
def test_index(
368+
method, sub, start, end, index_or_series, any_string_dtype, expected, request
369+
):
368370
if index_or_series is Index and not any_string_dtype == "object":
369-
pytest.skip("Index cannot yet be backed by a StringArray/ArrowStringArray")
371+
mark = pytest.mark.xfail(reason="Need EA-backed Index")
372+
request.node.add_marker(mark)
370373

371374
obj = index_or_series(
372375
["ABCDEFG", "BCDEFEF", "DEFGHIJEF", "EFGHEF"], dtype=any_string_dtype

0 commit comments

Comments
 (0)