Skip to content

Commit e4b21f6

Browse files
committed
TST: Change rops tests
1 parent e903550 commit e4b21f6

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

pandas/tests/series/test_operators.py

+14-18
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from pandas import (
1515
Categorical, DataFrame, Index, NaT, Series, bdate_range, date_range, isna)
1616
from pandas.core import ops
17-
from pandas.core.indexes.base import InvalidIndexError
1817
import pandas.core.nanops as nanops
1918
import pandas.util.testing as tm
2019
from pandas.util.testing import (
@@ -190,23 +189,7 @@ def test_scalar_na_logical_ops_corners(self):
190189
operator.and_,
191190
operator.or_,
192191
operator.xor,
193-
pytest.param(ops.rand_,
194-
marks=pytest.mark.xfail(reason="GH#22092 Index "
195-
"implementation returns "
196-
"Index",
197-
raises=AssertionError,
198-
strict=True)),
199-
pytest.param(ops.ror_,
200-
marks=pytest.mark.xfail(reason="GH#22092 Index "
201-
"implementation raises",
202-
raises=InvalidIndexError,
203-
strict=True)),
204-
pytest.param(ops.rxor,
205-
marks=pytest.mark.xfail(reason="GH#22092 Index "
206-
"implementation returns "
207-
"Index",
208-
raises=AssertionError,
209-
strict=True))
192+
210193
])
211194
def test_logical_ops_with_index(self, op):
212195
# GH#22092, GH#19792
@@ -225,6 +208,19 @@ def test_logical_ops_with_index(self, op):
225208
result = op(ser, idx2)
226209
assert_series_equal(result, expected)
227210

211+
@pytest.mark.parametrize("op, expected", [
212+
(ops.rand_, pd.Index([False, True])),
213+
(ops.ror_, pd.Index([False, True])),
214+
(ops.rxor, pd.Index([])),
215+
])
216+
def test_reverse_ops_with_index(self, op, expected):
217+
# https://github.com/pandas-dev/pandas/pull/23628
218+
# multi-set Index ops are buggy, so let's avoid duplicates...
219+
ser = Series([True, False])
220+
idx = Index([False, True])
221+
result = op(ser, idx)
222+
tm.assert_index_equal(result, expected)
223+
228224
def test_logical_ops_label_based(self):
229225
# GH#4947
230226
# logical ops should be label based

0 commit comments

Comments
 (0)