Skip to content

Commit 7feb79b

Browse files
author
Jean-Francois Zinque
committed
TST: Fix MultiIndex intersection test not testing sort=False order
1 parent 5c37a0b commit 7feb79b

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

pandas/tests/indexes/multi/test_setops.py

+9-13
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,17 @@ def test_set_ops_error_cases(idx, case, sort, method):
2020

2121
@pytest.mark.parametrize("sort", [None, False])
2222
def test_intersection_base(idx, sort):
23-
first = idx[:5]
24-
second = idx[:3]
25-
intersect = first.intersection(second, sort=sort)
26-
27-
if sort is None:
28-
tm.assert_index_equal(intersect, second.sort_values())
29-
assert tm.equalContents(intersect, second)
23+
first = idx[2::-1] # first 3 elements reversed
24+
second = idx[:5]
3025

31-
# GH 10149
32-
cases = [klass(second.values) for klass in [np.array, Series, list]]
33-
for case in cases:
34-
result = first.intersection(case, sort=sort)
26+
array_like_cases = [klass(second.values) for klass in [np.array, Series, list]]
27+
for case in [second, *array_like_cases]:
28+
intersect = first.intersection(case, sort=sort)
3529
if sort is None:
36-
tm.assert_index_equal(result, second.sort_values())
37-
assert tm.equalContents(result, second)
30+
expected = first.sort_values()
31+
else:
32+
expected = first
33+
tm.assert_index_equal(intersect, expected)
3834

3935
msg = "other must be a MultiIndex or a list of tuples"
4036
with pytest.raises(TypeError, match=msg):

0 commit comments

Comments
 (0)