Skip to content

Commit 24652cf

Browse files
authored
TST: Convert skip -> xfail (#46427)
1 parent 1f8cf19 commit 24652cf

File tree

6 files changed

+52
-33
lines changed

6 files changed

+52
-33
lines changed

pandas/tests/extension/base/methods.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class BaseMethodsTests(BaseExtensionTests):
1818
def test_value_counts_default_dropna(self, data):
1919
# make sure we have consistent default dropna kwarg
2020
if not hasattr(data, "value_counts"):
21-
pytest.skip("value_counts is not implemented")
21+
pytest.skip(f"value_counts is not implemented for {type(data)}")
2222
sig = inspect.signature(data.value_counts)
2323
kwarg = sig.parameters["dropna"]
2424
assert kwarg.default is True

pandas/tests/extension/json/test_json.py

+28-19
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,14 @@ def test_series_constructor_scalar_with_index(self, data, dtype):
190190

191191

192192
class TestReshaping(BaseJSON, base.BaseReshapingTests):
193-
@pytest.mark.skip(reason="Different definitions of NA")
193+
@pytest.mark.xfail(reason="Different definitions of NA")
194194
def test_stack(self):
195195
"""
196196
The test does .astype(object).stack(). If we happen to have
197197
any missing values in `data`, then we'll end up with different
198198
rows since we consider `{}` NA, but `.astype(object)` doesn't.
199199
"""
200+
super().test_stack()
200201

201202
@pytest.mark.xfail(reason="dict for NA")
202203
def test_unstack(self, data, index):
@@ -214,16 +215,18 @@ class TestIndex(BaseJSON, base.BaseIndexTests):
214215

215216

216217
class TestMissing(BaseJSON, base.BaseMissingTests):
217-
@pytest.mark.skip(reason="Setting a dict as a scalar")
218+
@pytest.mark.xfail(reason="Setting a dict as a scalar")
218219
def test_fillna_series(self):
219220
"""We treat dictionaries as a mapping in fillna, not a scalar."""
221+
super().test_fillna_series()
220222

221-
@pytest.mark.skip(reason="Setting a dict as a scalar")
223+
@pytest.mark.xfail(reason="Setting a dict as a scalar")
222224
def test_fillna_frame(self):
223225
"""We treat dictionaries as a mapping in fillna, not a scalar."""
226+
super().test_fillna_frame()
224227

225228

226-
unhashable = pytest.mark.skip(reason="Unhashable")
229+
unhashable = pytest.mark.xfail(reason="Unhashable")
227230

228231

229232
class TestReduce(base.BaseNoReduceTests):
@@ -233,16 +236,16 @@ class TestReduce(base.BaseNoReduceTests):
233236
class TestMethods(BaseJSON, base.BaseMethodsTests):
234237
@unhashable
235238
def test_value_counts(self, all_data, dropna):
236-
pass
239+
super().test_value_counts(all_data, dropna)
237240

238241
@unhashable
239242
def test_value_counts_with_normalize(self, data):
240-
pass
243+
super().test_value_counts_with_normalize(data)
241244

242245
@unhashable
243246
def test_sort_values_frame(self):
244247
# TODO (EA.factorize): see if _values_for_factorize allows this.
245-
pass
248+
super().test_sort_values_frame()
246249

247250
@pytest.mark.parametrize("ascending", [True, False])
248251
def test_sort_values(self, data_for_sorting, ascending, sort_by_key):
@@ -256,45 +259,46 @@ def test_sort_values_missing(
256259
data_missing_for_sorting, ascending, sort_by_key
257260
)
258261

259-
@pytest.mark.skip(reason="combine for JSONArray not supported")
262+
@pytest.mark.xfail(reason="combine for JSONArray not supported")
260263
def test_combine_le(self, data_repeated):
261-
pass
264+
super().test_combine_le(data_repeated)
262265

263-
@pytest.mark.skip(reason="combine for JSONArray not supported")
266+
@pytest.mark.xfail(reason="combine for JSONArray not supported")
264267
def test_combine_add(self, data_repeated):
265-
pass
268+
super().test_combine_add(data_repeated)
266269

267-
@pytest.mark.skip(reason="combine for JSONArray not supported")
270+
@pytest.mark.xfail(reason="combine for JSONArray not supported")
268271
def test_combine_first(self, data):
269-
pass
272+
super().test_combine_first(data)
270273

271274
@unhashable
272275
def test_hash_pandas_object_works(self, data, kind):
273276
super().test_hash_pandas_object_works(data, kind)
274277

275-
@pytest.mark.skip(reason="broadcasting error")
278+
@pytest.mark.xfail(reason="broadcasting error")
276279
def test_where_series(self, data, na_value):
277280
# Fails with
278281
# *** ValueError: operands could not be broadcast together
279282
# with shapes (4,) (4,) (0,)
280283
super().test_where_series(data, na_value)
281284

282-
@pytest.mark.skip(reason="Can't compare dicts.")
285+
@pytest.mark.xfail(reason="Can't compare dicts.")
283286
def test_searchsorted(self, data_for_sorting):
284287
super().test_searchsorted(data_for_sorting)
285288

286-
@pytest.mark.skip(reason="Can't compare dicts.")
289+
@pytest.mark.xfail(reason="Can't compare dicts.")
287290
def test_equals(self, data, na_value, as_series):
288-
pass
291+
super().test_equals(data, na_value, as_series)
289292

290293

291294
class TestCasting(BaseJSON, base.BaseCastingTests):
292-
@pytest.mark.skip(reason="failing on np.array(self, dtype=str)")
295+
@pytest.mark.xfail(reason="failing on np.array(self, dtype=str)")
293296
def test_astype_str(self):
294297
"""This currently fails in NumPy on np.array(self, dtype=str) with
295298
296299
*** ValueError: setting an array element with a sequence
297300
"""
301+
super().test_astype_str()
298302

299303

300304
# We intentionally don't run base.BaseSetitemTests because pandas'
@@ -310,6 +314,7 @@ def test_groupby_extension_transform(self):
310314
I think this is what we want, i.e. `.name` should be the original
311315
values, and not the values for factorization.
312316
"""
317+
super().test_groupby_extension_transform()
313318

314319
@unhashable
315320
def test_groupby_extension_apply(self):
@@ -322,20 +327,23 @@ def test_groupby_extension_apply(self):
322327
I suspect that once we support Index[ExtensionArray],
323328
we'll be able to dispatch unique.
324329
"""
330+
super().test_groupby_extension_apply()
325331

326332
@unhashable
327333
def test_groupby_extension_agg(self):
328334
"""
329335
This fails when we get to tm.assert_series_equal when left.index
330336
contains dictionaries, which are not hashable.
331337
"""
338+
super().test_groupby_extension_agg()
332339

333340
@unhashable
334341
def test_groupby_extension_no_sort(self):
335342
"""
336343
This fails when we get to tm.assert_series_equal when left.index
337344
contains dictionaries, which are not hashable.
338345
"""
346+
super().test_groupby_extension_no_sort()
339347

340348
@pytest.mark.xfail(reason="GH#39098: Converts agg result to object")
341349
def test_groupby_agg_extension(self, data_for_grouping):
@@ -354,10 +362,11 @@ def test_add_series_with_extension_array(self, data):
354362
with pytest.raises(TypeError, match="unsupported"):
355363
ser + data
356364

365+
@pytest.mark.xfail(reason="not implemented")
357366
def test_divmod_series_array(self):
358367
# GH 23287
359368
# skipping because it is not implemented
360-
pass
369+
super().test_divmod_series_array()
361370

362371
def _check_divmod_op(self, s, op, other, exc=NotImplementedError):
363372
return super()._check_divmod_op(s, op, other, exc=TypeError)

pandas/tests/extension/test_sparse.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,10 @@ def test_fillna_series_method(self, data_missing):
266266
with tm.assert_produces_warning(PerformanceWarning):
267267
super().test_fillna_limit_backfill(data_missing)
268268

269-
@pytest.mark.skip(reason="Unsupported")
269+
@pytest.mark.xfail(reason="Unsupported")
270270
def test_fillna_series(self):
271271
# this one looks doable.
272-
pass
272+
super(self).test_fillna_series()
273273

274274
def test_fillna_frame(self, data_missing):
275275
# Have to override to specify that fill_value will change.
@@ -337,9 +337,9 @@ def test_fillna_copy_series(self, data_missing):
337337
assert ser._values is not result._values
338338
assert ser._values.to_dense() is arr.to_dense()
339339

340-
@pytest.mark.skip(reason="Not Applicable")
340+
@pytest.mark.xfail(reason="Not Applicable")
341341
def test_fillna_length_mismatch(self, data_missing):
342-
pass
342+
super().test_fillna_length_mismatch(data_missing)
343343

344344
def test_where_series(self, data, na_value):
345345
assert data[0] != data[1]

pandas/tests/indexes/test_common.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -454,12 +454,16 @@ def test_sort_values_invalid_na_position(index_with_missing, na_position):
454454

455455

456456
@pytest.mark.parametrize("na_position", ["first", "last"])
457-
def test_sort_values_with_missing(index_with_missing, na_position):
457+
def test_sort_values_with_missing(index_with_missing, na_position, request):
458458
# GH 35584. Test that sort_values works with missing values,
459459
# sort non-missing and place missing according to na_position
460460

461461
if isinstance(index_with_missing, CategoricalIndex):
462-
pytest.skip("missing value sorting order not well-defined")
462+
request.node.add_marker(
463+
pytest.mark.xfail(
464+
reason="missing value sorting order not well-defined", strict=False
465+
)
466+
)
463467

464468
missing_count = np.sum(index_with_missing.isna())
465469
not_na_vals = index_with_missing[index_with_missing.notna()].values

pandas/tests/io/excel/test_writers.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
option_context,
2222
)
2323
import pandas._testing as tm
24+
from pandas.util.version import Version
2425

2526
from pandas.io.excel import (
2627
ExcelFile,
@@ -1087,8 +1088,8 @@ def test_comment_empty_line(self, path):
10871088
result = pd.read_excel(path, comment="#")
10881089
tm.assert_frame_equal(result, expected)
10891090

1090-
def test_datetimes(self, path):
1091-
1091+
def test_datetimes(self, path, request):
1092+
openpyxl = pytest.importorskip("openpyxl")
10921093
# Test writing and reading datetimes. For issue #9139. (xref #9185)
10931094
datetimes = [
10941095
datetime(2013, 1, 13, 1, 2, 3),
@@ -1106,10 +1107,15 @@ def test_datetimes(self, path):
11061107

11071108
write_frame = DataFrame({"A": datetimes})
11081109
write_frame.to_excel(path, "Sheet1")
1109-
if path.endswith("xlsx") or path.endswith("xlsm"):
1110-
pytest.skip(
1111-
"Defaults to openpyxl and fails with floating point error on "
1112-
"datetimes; may be fixed on newer versions of openpyxl - GH #38644"
1110+
if (path.endswith("xlsx") or path.endswith("xlsm")) and Version(
1111+
openpyxl.__version__
1112+
) < Version("3.0.6"):
1113+
request.node.add_marker(
1114+
pytest.mark.xfail(
1115+
reason="Defaults to openpyxl and fails with "
1116+
"floating point error on datetimes; may be fixed on "
1117+
"newer versions of openpyxl - GH #38644"
1118+
)
11131119
)
11141120
read_frame = pd.read_excel(path, sheet_name="Sheet1", header=0)
11151121

pandas/tests/io/formats/test_info.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ def test_info_memory_usage_deep_not_pypy():
388388
assert df_object.memory_usage(deep=True).sum() > df_object.memory_usage().sum()
389389

390390

391-
@pytest.mark.skipif(not PYPY, reason="on PyPy deep=True does not change result")
391+
@pytest.mark.xfail(not PYPY, reason="on PyPy deep=True does not change result")
392392
def test_info_memory_usage_deep_pypy():
393393
df_with_object_index = DataFrame({"a": [1]}, index=["foo"])
394394
assert (

0 commit comments

Comments
 (0)