Skip to content
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

TST: skips in extension.test_categorical #39062

Merged
merged 3 commits into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion pandas/tests/extension/base/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,10 @@ def test_hash_pandas_object_works(self, data, as_frame):

def test_searchsorted(self, data_for_sorting, as_series):
b, c, a = data_for_sorting
arr = type(data_for_sorting)._from_sequence([a, b, c])
# Pass dtype so sorting order is not lost for Categorical
arr = type(data_for_sorting)._from_sequence(
[a, b, c], dtype=data_for_sorting.dtype
)

if as_series:
arr = pd.Series(arr)
Expand Down
34 changes: 19 additions & 15 deletions pandas/tests/extension/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,8 @@ def test_combine_add(self, data_repeated):
def test_fillna_length_mismatch(self, data_missing):
super().test_fillna_length_mismatch(data_missing)

def test_searchsorted(self, data_for_sorting):
if not data_for_sorting.ordered:
raise pytest.skip(reason="searchsorted requires ordered data.")
def test_searchsorted(self, data_for_sorting, as_series):
super().test_searchsorted(data_for_sorting, as_series)


class TestCasting(base.BaseCastingTests):
Expand Down Expand Up @@ -229,21 +228,26 @@ def test_consistent_casting(self, dtype, expected):


class TestArithmeticOps(base.BaseArithmeticOpsTests):
def test_arith_frame_with_scalar(self, data, all_arithmetic_operators):
def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request):
# frame & scalar
op_name = all_arithmetic_operators
if op_name != "__rmod__":
super().test_arith_frame_with_scalar(data, all_arithmetic_operators)
else:
pytest.skip("rmod never called when string is first argument")

def test_arith_series_with_scalar(self, data, all_arithmetic_operators):

if op_name == "__rmod__":
request.node.add_marker(
pytest.mark.xfail(
Copy link
Member

Choose a reason for hiding this comment

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

Is this change related? (I wouldn't know if an xfail is more appropriate here than a skip)

Copy link
Member Author

Choose a reason for hiding this comment

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

Related to #38904 that this PR is trying to close, but not to the other skip/xfail in this PR. Will split off into a separate PR if desired.

This test is doing op(Series, const) expecting it to raise, where Series consists of and const is a string. There is no rmod in the python library operator, and so the test is instead doing lambda x, y: mod(const, Series) . This doesn't raise.

This is always expected to "fail" (meaning not raise), and I think we'd want to know if it didn't. This is why I went with xfail over skip here.

reason="rmod never called when string is first argument"
)
)
super().test_arith_frame_with_scalar(data, op_name)

def test_arith_series_with_scalar(self, data, all_arithmetic_operators, request):
op_name = all_arithmetic_operators
if op_name != "__rmod__":
super().test_arith_series_with_scalar(data, op_name)
else:
pytest.skip("rmod never called when string is first argument")
if op_name == "__rmod__":
request.node.add_marker(
pytest.mark.xfail(
reason="rmod never called when string is first argument"
)
)
super().test_arith_series_with_scalar(data, op_name)

def test_add_series_with_extension_array(self, data):
ser = pd.Series(data)
Expand Down