Skip to content

TST: tighten xfails in test_strings #33932

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 2 commits into from
May 2, 2020
Merged
Changes from all 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
50 changes: 19 additions & 31 deletions pandas/tests/test_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,19 +209,8 @@ def test_api_per_dtype(self, index_or_series, dtype, any_skipna_inferred_dtype):
box = index_or_series
inferred_dtype, values = any_skipna_inferred_dtype

if dtype == "category" and len(values) and values[1] is pd.NA:
pytest.xfail(reason="Categorical does not yet support pd.NA")

t = box(values, dtype=dtype) # explicit dtype to avoid casting

# TODO: get rid of these xfails
if dtype == "category" and inferred_dtype in ["period", "interval"]:
pytest.xfail(
reason="Conversion to numpy array fails because "
"the ._values-attribute is not a numpy array for "
"PeriodArray/IntervalArray; see GH 23553"
)

types_passing_constructor = [
"string",
"unicode",
Expand All @@ -247,6 +236,7 @@ def test_api_per_method(
dtype,
any_allowed_skipna_inferred_dtype,
any_string_method,
request,
):
# this test does not check correctness of the different methods,
# just that the methods work on the specified (inferred) dtypes,
Expand All @@ -258,26 +248,24 @@ def test_api_per_method(
method_name, args, kwargs = any_string_method

# TODO: get rid of these xfails
if (
method_name in ["partition", "rpartition"]
and box == Index
and inferred_dtype == "empty"
):
pytest.xfail(reason="Method cannot deal with empty Index")
if (
method_name == "split"
and box == Index
and values.size == 0
and kwargs.get("expand", None) is not None
):
pytest.xfail(reason="Split fails on empty Series when expand=True")
if (
method_name == "get_dummies"
and box == Index
and inferred_dtype == "empty"
and (dtype == object or values.size == 0)
):
pytest.xfail(reason="Need to fortify get_dummies corner cases")
reason = None
if box is Index and values.size == 0:
if method_name in ["partition", "rpartition"] and kwargs.get(
"expand", True
):
reason = "Method cannot deal with empty Index"
elif method_name == "split" and kwargs.get("expand", None):
reason = "Split fails on empty Series when expand=True"
elif method_name == "get_dummies":
reason = "Need to fortify get_dummies corner cases"

elif box is Index and inferred_dtype == "empty" and dtype == object:
if method_name == "get_dummies":
reason = "Need to fortify get_dummies corner cases"

if reason is not None:
mark = pytest.mark.xfail(reason=reason)
request.node.add_marker(mark)

t = box(values, dtype=dtype) # explicit dtype to avoid casting
method = getattr(t.str, method_name)
Expand Down