Skip to content

TST: Replace pytest.xfail #38929

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
Jan 4, 2021
Merged
Show file tree
Hide file tree
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
20 changes: 14 additions & 6 deletions pandas/tests/indexes/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,22 +386,30 @@ def test_asi8_deprecation(self, index):


@pytest.mark.parametrize("na_position", [None, "middle"])
def test_sort_values_invalid_na_position(index_with_missing, na_position):
if isinstance(index_with_missing, (CategoricalIndex, MultiIndex)):
pytest.xfail("missing value sorting order not defined for index type")
def test_sort_values_invalid_na_position(request, index_with_missing, na_position):
if isinstance(index_with_missing, MultiIndex):
request.node.add_marker(
pytest.mark.xfail(
reason="missing value sorting order not defined for index type"
)
)

if na_position not in ["first", "last"]:
with pytest.raises(ValueError, match=f"invalid na_position: {na_position}"):
index_with_missing.sort_values(na_position=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(request, index_with_missing, na_position):
# 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, MultiIndex)):
pytest.xfail("missing value sorting order not defined for index type")
if isinstance(index_with_missing, MultiIndex):
request.node.add_marker(
pytest.mark.xfail(reason="missing value sorting order not implemented")
)
elif isinstance(index_with_missing, CategoricalIndex):
pytest.skip("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
2 changes: 1 addition & 1 deletion pandas/tests/indexes/test_setops.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_union_different_types(request, index, index_fixture2):
)

if any(isinstance(idx, pd.MultiIndex) for idx in (idx1, idx2)):
pytest.xfail("This test doesn't consider multiindixes.")
pytest.skip("This test doesn't consider multiindixes.")

if is_dtype_equal(idx1.dtype, idx2.dtype):
pytest.skip("This test only considers non matching dtypes.")
Expand Down
11 changes: 6 additions & 5 deletions pandas/tests/series/indexing/test_setitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,15 @@ def test_series_where(self, obj, key, expected):
tm.assert_series_equal(res, expected)

def test_index_where(self, obj, key, expected, request):
if obj.dtype == bool:
msg = "Index/Series casting behavior inconsistent GH#38692"
mark = pytest.xfail(reason=msg)
request.node.add_marker(mark)

mask = np.zeros(obj.shape, dtype=bool)
mask[key] = True

if obj.dtype == bool and not mask.all():
# When mask is all True, casting behavior does not apply
msg = "Index/Series casting behavior inconsistent GH#38692"
mark = pytest.mark.xfail(reason=msg)
request.node.add_marker(mark)

res = Index(obj).where(~mask, np.nan)
tm.assert_index_equal(res, Index(expected))

Expand Down
6 changes: 1 addition & 5 deletions pandas/tests/series/indexing/test_where.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,6 @@ def test_where_datetimelike_categorical(tz_naive_fixture):
tm.assert_series_equal(res, Series(dr))

# DataFrame.where
if tz is None:
res = pd.DataFrame(lvals).where(mask[:, None], pd.DataFrame(rvals))
else:
with pytest.xfail(reason="frame._values loses tz"):
res = pd.DataFrame(lvals).where(mask[:, None], pd.DataFrame(rvals))
res = pd.DataFrame(lvals).where(mask[:, None], pd.DataFrame(rvals))

tm.assert_frame_equal(res, pd.DataFrame(dr))
12 changes: 9 additions & 3 deletions pandas/tests/series/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,12 +737,18 @@ def test_align_date_objects_with_datetimeindex(self):
class TestNamePreservation:
@pytest.mark.parametrize("box", [list, tuple, np.array, Index, Series, pd.array])
@pytest.mark.parametrize("flex", [True, False])
def test_series_ops_name_retention(self, flex, box, names, all_binary_operators):
def test_series_ops_name_retention(
self, request, flex, box, names, all_binary_operators
):
# GH#33930 consistent name renteiton
op = all_binary_operators

if op is ops.rfloordiv and box in [list, tuple]:
pytest.xfail("op fails because of inconsistent ndarray-wrapping GH#28759")
if op is ops.rfloordiv and box in [list, tuple] and not flex:
request.node.add_marker(
pytest.mark.xfail(
reason="op fails because of inconsistent ndarray-wrapping GH#28759"
)
)

left = Series(range(10), name=names[0])
right = Series(range(10), name=names[1])
Expand Down