Skip to content

Commit 0635a25

Browse files
authored
CLN/TST: skips -> xfails (#44744)
1 parent 1cbe011 commit 0635a25

19 files changed

+65
-63
lines changed

pandas/_testing/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,14 +1077,16 @@ def shares_memory(left, right) -> bool:
10771077

10781078
if isinstance(left, NDArrayBackedExtensionArray):
10791079
return shares_memory(left._ndarray, right)
1080-
if isinstance(left, pd.SparseArray):
1080+
if isinstance(left, pd.core.arrays.SparseArray):
10811081
return shares_memory(left.sp_values, right)
10821082

10831083
if isinstance(left, ExtensionArray) and left.dtype == "string[pyarrow]":
10841084
# https://github.com/pandas-dev/pandas/pull/43930#discussion_r736862669
10851085
if isinstance(right, ExtensionArray) and right.dtype == "string[pyarrow]":
1086-
left_pa_data = left._data
1087-
right_pa_data = right._data
1086+
# error: "ExtensionArray" has no attribute "_data"
1087+
left_pa_data = left._data # type: ignore[attr-defined]
1088+
# error: "ExtensionArray" has no attribute "_data"
1089+
right_pa_data = right._data # type: ignore[attr-defined]
10881090
left_buf1 = left_pa_data.chunk(0).buffers()[1]
10891091
right_buf1 = right_pa_data.chunk(0).buffers()[1]
10901092
return left_buf1 == right_buf1

pandas/tests/apply/test_frame_transform.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,6 @@ def test_transform_bad_dtype(op, frame_or_series, request):
160160
@pytest.mark.parametrize("op", frame_kernels_raise)
161161
def test_transform_partial_failure_typeerror(op):
162162
# GH 35964
163-
if op == "rank":
164-
pytest.skip("GH 40418: rank does not raise a TypeError")
165163

166164
# Using object makes most transform kernels fail
167165
df = DataFrame({"A": 3 * [object], "B": [1, 2, 3]})

pandas/tests/extension/arrow/test_bool.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ class BaseArrowTests:
4141

4242

4343
class TestDtype(BaseArrowTests, base.BaseDtypeTests):
44-
def test_array_type_with_arg(self, data, dtype):
45-
pytest.skip("GH-22666")
44+
pass
4645

4746

4847
class TestInterface(BaseArrowTests, base.BaseInterfaceTests):
@@ -63,9 +62,6 @@ def test_contains(self, data, data_missing):
6362

6463

6564
class TestConstructors(BaseArrowTests, base.BaseConstructorsTests):
66-
def test_from_dtype(self, data):
67-
pytest.skip("GH-22666")
68-
6965
# seems like some bug in isna on empty BoolArray returning floats.
7066
@pytest.mark.xfail(reason="bad is-na for empty data")
7167
def test_from_sequence_from_cls(self, data):

pandas/tests/extension/test_boolean.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,13 @@ def test_searchsorted(self, data_for_sorting, as_series):
208208
sorter = np.array([1, 0])
209209
assert data_for_sorting.searchsorted(a, sorter=sorter) == 0
210210

211-
@pytest.mark.skip(reason="uses nullable integer")
211+
@pytest.mark.xfail(reason="uses nullable integer")
212212
def test_value_counts(self, all_data, dropna):
213213
return super().test_value_counts(all_data, dropna)
214214

215-
@pytest.mark.skip(reason="uses nullable integer")
215+
@pytest.mark.xfail(reason="uses nullable integer")
216216
def test_value_counts_with_normalize(self, data):
217-
pass
217+
super().test_value_counts_with_normalize(data)
218218

219219
def test_argmin_argmax(self, data_for_sorting, data_missing_for_sorting):
220220
# override because there are only 2 unique values

pandas/tests/extension/test_floating.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ class TestMissing(base.BaseMissingTests):
169169

170170

171171
class TestMethods(base.BaseMethodsTests):
172+
# TODO(ExtensionIndex): re-enable
172173
@pytest.mark.skip(reason="uses nullable integer")
174+
@pytest.mark.parametrize("dropna", [True, False])
173175
def test_value_counts(self, all_data, dropna):
174176
all_data = all_data[:10]
175177
if dropna:
@@ -183,9 +185,9 @@ def test_value_counts(self, all_data, dropna):
183185

184186
self.assert_series_equal(result, expected)
185187

186-
@pytest.mark.skip(reason="uses nullable integer")
188+
@pytest.mark.xfail(reason="uses nullable integer")
187189
def test_value_counts_with_normalize(self, data):
188-
pass
190+
super().test_value_counts_with_normalize(data)
189191

190192

191193
class TestCasting(base.BaseCastingTests):

pandas/tests/extension/test_integer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ class TestMissing(base.BaseMissingTests):
192192

193193

194194
class TestMethods(base.BaseMethodsTests):
195+
# TODO(ExtensionIndex): re-enable
195196
@pytest.mark.skip(reason="uses nullable integer")
196197
@pytest.mark.parametrize("dropna", [True, False])
197198
def test_value_counts(self, all_data, dropna):
@@ -207,9 +208,9 @@ def test_value_counts(self, all_data, dropna):
207208

208209
self.assert_series_equal(result, expected)
209210

210-
@pytest.mark.skip(reason="uses nullable integer")
211+
@pytest.mark.xfail(reason="uses nullable integer")
211212
def test_value_counts_with_normalize(self, data):
212-
pass
213+
super().test_value_counts_with_normalize(data)
213214

214215

215216
class TestCasting(base.BaseCastingTests):

pandas/tests/extension/test_interval.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ class TestGrouping(BaseInterval, base.BaseGroupbyTests):
9595

9696

9797
class TestInterface(BaseInterval, base.BaseInterfaceTests):
98-
def test_view(self, data):
99-
# __setitem__ incorrectly makes a copy (GH#27147), so we only
100-
# have a smoke-test
101-
data.view()
98+
pass
10299

103100

104101
class TestReduce(base.BaseNoReduceTests):

pandas/tests/extension/test_sparse.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,6 @@ def test_array_type_with_arg(self, data, dtype):
116116

117117

118118
class TestInterface(BaseSparseTests, base.BaseInterfaceTests):
119-
def test_no_values_attribute(self, data):
120-
pytest.skip("We have values")
121-
122119
def test_copy(self, data):
123120
# __setitem__ does not work, so we only have a smoke-test
124121
data.copy()

pandas/tests/frame/test_reductions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1492,7 +1492,7 @@ def test_reductions_deprecation_level_argument(
14921492

14931493
def test_reductions_skipna_none_raises(self, frame_or_series, reduction_functions):
14941494
if reduction_functions in ["count", "mad"]:
1495-
pytest.skip("Count does not accept skipna. Mad needs a depreaction cycle.")
1495+
pytest.skip("Count does not accept skipna. Mad needs a deprecation cycle.")
14961496
obj = frame_or_series([1, 2, 3])
14971497
msg = 'For argument "skipna" expected type bool, received type NoneType.'
14981498
with pytest.raises(ValueError, match=msg):

pandas/tests/generic/test_to_xarray.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ def df(self):
3030
}
3131
)
3232

33-
def test_to_xarray_index_types(self, index, df):
34-
if isinstance(index, MultiIndex):
35-
pytest.skip("MultiIndex is tested separately")
33+
def test_to_xarray_index_types(self, index_flat, df):
34+
index = index_flat
35+
# MultiIndex is tested in test_to_xarray_with_multiindex
3636
if len(index) == 0:
3737
pytest.skip("Test doesn't make sense for empty index")
3838

@@ -86,9 +86,9 @@ def test_to_xarray_with_multiindex(self, df):
8686

8787
@td.skip_if_no("xarray")
8888
class TestSeriesToXArray:
89-
def test_to_xarray_index_types(self, index):
90-
if isinstance(index, MultiIndex):
91-
pytest.skip("MultiIndex is tested separately")
89+
def test_to_xarray_index_types(self, index_flat):
90+
index = index_flat
91+
# MultiIndex is tested in test_to_xarray_with_multiindex
9292

9393
from xarray import DataArray
9494

pandas/tests/indexes/interval/test_constructors.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,6 @@ def test_constructor_string(self, constructor, breaks):
178178
@pytest.mark.parametrize("cat_constructor", [Categorical, CategoricalIndex])
179179
def test_constructor_categorical_valid(self, constructor, cat_constructor):
180180
# GH 21243/21253
181-
if isinstance(constructor, partial) and constructor.func is Index:
182-
# Index is defined to create CategoricalIndex from categorical data
183-
pytest.skip()
184181

185182
breaks = np.arange(10, dtype="int64")
186183
expected = IntervalIndex.from_breaks(breaks)

pandas/tests/indexes/multi/test_analytics.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,6 @@ def test_map(idx):
187187
)
188188
def test_map_dictlike(idx, mapper):
189189

190-
if isinstance(idx, (pd.CategoricalIndex, pd.IntervalIndex)):
191-
pytest.skip(f"skipping tests for {type(idx)}")
192-
193190
identity = mapper(idx.values, idx)
194191

195192
# we don't infer to UInt64 for a dict

pandas/tests/io/excel/test_xlrd.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,35 @@
1515
xlrd = pytest.importorskip("xlrd")
1616
xlwt = pytest.importorskip("xlwt")
1717

18+
pytestmark = pytest.mark.filterwarnings(
19+
"ignore:As the xlwt package is no longer maintained:FutureWarning"
20+
)
21+
22+
23+
# error: Unsupported operand types for <= ("Version" and "None")
24+
if xlrd_version >= Version("2"): # type: ignore[operator]
25+
exts = [".xls"]
26+
else:
27+
exts = [".xls", ".xlsx", ".xlsm"]
28+
29+
30+
@pytest.fixture(params=exts)
31+
def read_ext_xlrd(request):
32+
"""
33+
Valid extensions for reading Excel files with xlrd.
1834
19-
@pytest.fixture(autouse=True)
20-
def skip_ods_and_xlsb_files(read_ext):
21-
if read_ext == ".ods":
22-
pytest.skip("Not valid for xlrd")
23-
if read_ext == ".xlsb":
24-
pytest.skip("Not valid for xlrd")
25-
if read_ext in (".xlsx", ".xlsm") and xlrd_version >= Version("2"):
26-
pytest.skip("Not valid for xlrd >= 2.0")
35+
Similar to read_ext, but excludes .ods, .xlsb, and for xlrd>2 .xlsx, .xlsm
36+
"""
37+
return request.param
2738

2839

29-
def test_read_xlrd_book(read_ext, frame):
40+
def test_read_xlrd_book(read_ext_xlrd, frame):
3041
df = frame
3142

3243
engine = "xlrd"
3344
sheet_name = "SheetA"
3445

35-
with tm.ensure_clean(read_ext) as pth:
46+
with tm.ensure_clean(read_ext_xlrd) as pth:
3647
df.to_excel(pth, sheet_name)
3748
book = xlrd.open_workbook(pth)
3849

pandas/tests/io/parser/common/test_float.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ def test_scientific_no_exponent(all_parsers_all_precisions):
3030
df = DataFrame.from_dict({"w": ["2e"], "x": ["3E"], "y": ["42e"], "z": ["632E"]})
3131
data = df.to_csv(index=False)
3232
parser, precision = all_parsers_all_precisions
33-
if parser == "pyarrow":
34-
pytest.skip()
3533

3634
df_roundtrip = parser.read_csv(StringIO(data), float_precision=precision)
3735
tm.assert_frame_equal(df_roundtrip, df)
@@ -41,8 +39,7 @@ def test_scientific_no_exponent(all_parsers_all_precisions):
4139
def test_very_negative_exponent(all_parsers_all_precisions, neg_exp):
4240
# GH#38753
4341
parser, precision = all_parsers_all_precisions
44-
if parser == "pyarrow":
45-
pytest.skip()
42+
4643
data = f"data\n10E{neg_exp}"
4744
result = parser.read_csv(StringIO(data), float_precision=precision)
4845
expected = DataFrame({"data": [0.0]})

pandas/tests/io/parser/common/test_read_errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def test_open_file(all_parsers):
245245
# GH 39024
246246
parser = all_parsers
247247
if parser.engine == "c":
248-
pytest.skip()
248+
pytest.skip("'c' engine does not support sep=None with delim_whitespace=False")
249249

250250
with tm.ensure_clean() as path:
251251
file = Path(path)

pandas/tests/io/parser/test_comment.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_comment(all_parsers, na_values):
3030
@pytest.mark.parametrize(
3131
"read_kwargs", [{}, {"lineterminator": "*"}, {"delim_whitespace": True}]
3232
)
33-
def test_line_comment(all_parsers, read_kwargs):
33+
def test_line_comment(all_parsers, read_kwargs, request):
3434
parser = all_parsers
3535
data = """# empty
3636
A,B,C
@@ -42,7 +42,10 @@ def test_line_comment(all_parsers, read_kwargs):
4242
data = data.replace(",", " ")
4343
elif read_kwargs.get("lineterminator"):
4444
if parser.engine != "c":
45-
pytest.skip("Custom terminator not supported with Python engine")
45+
mark = pytest.mark.xfail(
46+
reason="Custom terminator not supported with Python engine"
47+
)
48+
request.node.add_marker(mark)
4649

4750
data = data.replace("\n", read_kwargs.get("lineterminator"))
4851

pandas/tests/io/parser/test_encoding.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,6 @@ def test_encoding_named_temp_file(all_parsers):
202202
parser = all_parsers
203203
encoding = "shift-jis"
204204

205-
if parser.engine == "python":
206-
pytest.skip("NamedTemporaryFile does not work with Python engine")
207-
208205
title = "てすと"
209206
data = "こむ"
210207

@@ -302,11 +299,15 @@ def test_readcsv_memmap_utf8(all_parsers):
302299
tm.assert_frame_equal(df, dfr)
303300

304301

305-
def test_not_readable(all_parsers):
302+
def test_not_readable(all_parsers, request):
306303
# GH43439
307304
parser = all_parsers
308305
if parser.engine in ("python", "pyarrow"):
309-
pytest.skip("SpooledTemporaryFile does only work with the c-engine")
306+
mark = pytest.mark.xfail(
307+
reason="SpooledTemporaryFile does only work with the c-engine"
308+
)
309+
request.node.add_marker(mark)
310+
310311
with tempfile.SpooledTemporaryFile() as handle:
311312
handle.write(b"abcd")
312313
handle.seek(0)

pandas/tests/io/parser/test_parse_dates.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,8 +1709,8 @@ def _helper_hypothesis_delimited_date(call, date_string, **kwargs):
17091709
def test_hypothesis_delimited_date(date_format, dayfirst, delimiter, test_datetime):
17101710
if date_format == "%m %Y" and delimiter == ".":
17111711
pytest.skip(
1712-
"parse_datetime_string cannot reliably tell whether \
1713-
e.g. %m.%Y is a float or a date, thus we skip it"
1712+
"parse_datetime_string cannot reliably tell whether "
1713+
"e.g. %m.%Y is a float or a date, thus we skip it"
17141714
)
17151715
result, expected = None, None
17161716
except_in_dateutil, except_out_dateutil = None, None

pandas/tests/io/test_parquet.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,13 +595,16 @@ def test_write_column_index_nonstring(self, pa):
595595
msg = r"parquet must have string column names"
596596
self.check_error_on_write(df, engine, ValueError, msg)
597597

598-
def test_use_nullable_dtypes(self, engine):
598+
def test_use_nullable_dtypes(self, engine, request):
599599
import pyarrow.parquet as pq
600600

601601
if engine == "fastparquet":
602602
# We are manually disabling fastparquet's
603603
# nullable dtype support pending discussion
604-
pytest.skip("Fastparquet nullable dtype support is disabled")
604+
mark = pytest.mark.xfail(
605+
reason="Fastparquet nullable dtype support is disabled"
606+
)
607+
request.node.add_marker(mark)
605608

606609
table = pyarrow.table(
607610
{

0 commit comments

Comments
 (0)