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

Lines changed: 5 additions & 3 deletions
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

Lines changed: 4 additions & 5 deletions
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

Lines changed: 5 additions & 6 deletions
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

Lines changed: 1 addition & 6 deletions
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

Lines changed: 5 additions & 6 deletions
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

Lines changed: 8 additions & 4 deletions
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 5 additions & 1 deletion
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

Lines changed: 4 additions & 3 deletions
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

Lines changed: 2 additions & 0 deletions
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)

0 commit comments

Comments
 (0)