Skip to content

TST: Convert skip -> xfail #46427

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 6 commits into from
Mar 20, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion pandas/tests/extension/base/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class BaseMethodsTests(BaseExtensionTests):
def test_value_counts_default_dropna(self, data):
# make sure we have consistent default dropna kwarg
if not hasattr(data, "value_counts"):
pytest.skip("value_counts is not implemented")
pytest.skip(f"value_counts is not implemented for {type(data)}")
sig = inspect.signature(data.value_counts)
kwarg = sig.parameters["dropna"]
assert kwarg.default is True
Expand Down
49 changes: 30 additions & 19 deletions pandas/tests/extension/json/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import pytest

from pandas.compat import PY310

import pandas as pd
import pandas._testing as tm
from pandas.tests.extension import base
Expand Down Expand Up @@ -190,13 +192,14 @@ def test_series_constructor_scalar_with_index(self, data, dtype):


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

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


class TestMissing(BaseJSON, base.BaseMissingTests):
@pytest.mark.skip(reason="Setting a dict as a scalar")
@pytest.mark.xfail(reason="Setting a dict as a scalar")
def test_fillna_series(self):
"""We treat dictionaries as a mapping in fillna, not a scalar."""
super().test_fillna_series()

@pytest.mark.skip(reason="Setting a dict as a scalar")
@pytest.mark.xfail(reason="Setting a dict as a scalar")
def test_fillna_frame(self):
"""We treat dictionaries as a mapping in fillna, not a scalar."""
super().test_fillna_frame()


unhashable = pytest.mark.skip(reason="Unhashable")
unhashable = pytest.mark.xfail(reason="Unhashable")


class TestReduce(base.BaseNoReduceTests):
Expand All @@ -233,16 +238,16 @@ class TestReduce(base.BaseNoReduceTests):
class TestMethods(BaseJSON, base.BaseMethodsTests):
@unhashable
def test_value_counts(self, all_data, dropna):
pass
super().test_value_counts(all_data, dropna)

@unhashable
def test_value_counts_with_normalize(self, data):
pass
super().test_value_counts_with_normalize(data)

@unhashable
def test_sort_values_frame(self):
# TODO (EA.factorize): see if _values_for_factorize allows this.
pass
super().test_sort_values_frame()

@pytest.mark.parametrize("ascending", [True, False])
def test_sort_values(self, data_for_sorting, ascending, sort_by_key):
Expand All @@ -256,45 +261,46 @@ def test_sort_values_missing(
data_missing_for_sorting, ascending, sort_by_key
)

@pytest.mark.skip(reason="combine for JSONArray not supported")
@pytest.mark.xfail(reason="combine for JSONArray not supported")
def test_combine_le(self, data_repeated):
pass
super().test_combine_le(data_repeated)

@pytest.mark.skip(reason="combine for JSONArray not supported")
@pytest.mark.xfail(reason="combine for JSONArray not supported")
def test_combine_add(self, data_repeated):
pass
super().test_combine_add(data_repeated)

@pytest.mark.skip(reason="combine for JSONArray not supported")
@pytest.mark.xfail(not PY310, reason="combine for JSONArray not supported")
def test_combine_first(self, data):
pass
super().test_combine_first(data)

@unhashable
def test_hash_pandas_object_works(self, data, kind):
super().test_hash_pandas_object_works(data, kind)

@pytest.mark.skip(reason="broadcasting error")
@pytest.mark.xfail(reason="broadcasting error")
def test_where_series(self, data, na_value):
# Fails with
# *** ValueError: operands could not be broadcast together
# with shapes (4,) (4,) (0,)
super().test_where_series(data, na_value)

@pytest.mark.skip(reason="Can't compare dicts.")
@pytest.mark.xfail(reason="Can't compare dicts.")
def test_searchsorted(self, data_for_sorting):
super().test_searchsorted(data_for_sorting)

@pytest.mark.skip(reason="Can't compare dicts.")
@pytest.mark.xfail(reason="Can't compare dicts.")
def test_equals(self, data, na_value, as_series):
pass
super().test_equals(data, na_value, as_series)


class TestCasting(BaseJSON, base.BaseCastingTests):
@pytest.mark.skip(reason="failing on np.array(self, dtype=str)")
@pytest.mark.xfail(reason="failing on np.array(self, dtype=str)")
def test_astype_str(self):
"""This currently fails in NumPy on np.array(self, dtype=str) with

*** ValueError: setting an array element with a sequence
"""
super().test_astype_str()


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

@unhashable
def test_groupby_extension_apply(self):
Expand All @@ -322,20 +329,23 @@ def test_groupby_extension_apply(self):
I suspect that once we support Index[ExtensionArray],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WillAyd we now support Index[EA] so this comment may now be addressable (im just guessing you wrote it)

we'll be able to dispatch unique.
"""
super().test_groupby_extension_apply()

@unhashable
def test_groupby_extension_agg(self):
"""
This fails when we get to tm.assert_series_equal when left.index
contains dictionaries, which are not hashable.
"""
super().test_groupby_extension_agg()

@unhashable
def test_groupby_extension_no_sort(self):
"""
This fails when we get to tm.assert_series_equal when left.index
contains dictionaries, which are not hashable.
"""
super().test_groupby_extension_no_sort()

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

@pytest.mark.xfail(reason="not implemented")
def test_divmod_series_array(self):
# GH 23287
# skipping because it is not implemented
pass
super().test_divmod_series_array()

def _check_divmod_op(self, s, op, other, exc=NotImplementedError):
return super()._check_divmod_op(s, op, other, exc=TypeError)
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/extension/test_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ def test_fillna_series_method(self, data_missing):
with tm.assert_produces_warning(PerformanceWarning):
super().test_fillna_limit_backfill(data_missing)

@pytest.mark.skip(reason="Unsupported")
@pytest.mark.xfail(reason="Unsupported")
def test_fillna_series(self):
# this one looks doable.
pass
super(self).test_fillna_series()

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

@pytest.mark.skip(reason="Not Applicable")
@pytest.mark.xfail(reason="Not Applicable")
def test_fillna_length_mismatch(self, data_missing):
pass
super().test_fillna_length_mismatch(data_missing)

def test_where_series(self, data, na_value):
assert data[0] != data[1]
Expand Down
6 changes: 4 additions & 2 deletions pandas/tests/indexes/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,12 +454,14 @@ def test_sort_values_invalid_na_position(index_with_missing, na_position):


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

if isinstance(index_with_missing, CategoricalIndex):
pytest.skip("missing value sorting order not well-defined")
request.node.add_marker(
pytest.mark.xfail(reason="missing value sorting order not well-defined")
)

missing_count = np.sum(index_with_missing.isna())
not_na_vals = index_with_missing[index_with_missing.notna()].values
Expand Down
18 changes: 12 additions & 6 deletions pandas/tests/io/excel/test_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
option_context,
)
import pandas._testing as tm
from pandas.util.version import Version

from pandas.io.excel import (
ExcelFile,
Expand Down Expand Up @@ -1087,8 +1088,8 @@ def test_comment_empty_line(self, path):
result = pd.read_excel(path, comment="#")
tm.assert_frame_equal(result, expected)

def test_datetimes(self, path):

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

write_frame = DataFrame({"A": datetimes})
write_frame.to_excel(path, "Sheet1")
if path.endswith("xlsx") or path.endswith("xlsm"):
pytest.skip(
"Defaults to openpyxl and fails with floating point error on "
"datetimes; may be fixed on newer versions of openpyxl - GH #38644"
if (path.endswith("xlsx") or path.endswith("xlsm")) and Version(
openpyxl.__version__
) > Version("3.0.6"):
request.node.add_marker(
pytest.mark.xfail(
reason="Defaults to openpyxl and fails with "
"floating point error on datetimes; may be fixed on "
"newer versions of openpyxl - GH #38644"
)
)
read_frame = pd.read_excel(path, sheet_name="Sheet1", header=0)

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/formats/test_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def test_info_memory_usage_deep_not_pypy():
assert df_object.memory_usage(deep=True).sum() > df_object.memory_usage().sum()


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