Skip to content

Commit 86bc7c0

Browse files
committed
Added unit test for new check_order param
1 parent e2f935c commit 86bc7c0

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

pandas/tests/util/test_assert_index_equal.py

+22
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,28 @@ def test_index_equal_values_too_far(check_exact, rtol):
115115
tm.assert_index_equal(idx1, idx2, **kwargs)
116116

117117

118+
@pytest.mark.parametrize("check_order", [True, False])
119+
def test_index_equal_value_oder_mismatch(check_exact, rtol, check_order):
120+
idx1 = Index([1, 2, 3])
121+
idx2 = Index([3, 2, 1])
122+
123+
msg = """Index are different
124+
125+
Index values are different \\(66\\.66667 %\\)
126+
\\[left\\]: Int64Index\\(\\[1, 2, 3\\], dtype='int64'\\)
127+
\\[right\\]: Int64Index\\(\\[3, 2, 1\\], dtype='int64'\\)"""
128+
129+
if check_order:
130+
with pytest.raises(AssertionError, match=msg):
131+
tm.assert_index_equal(
132+
idx1, idx2, check_exact=check_exact, rtol=rtol, check_order=True
133+
)
134+
else:
135+
tm.assert_index_equal(
136+
idx1, idx2, check_exact=check_exact, rtol=rtol, check_order=False
137+
)
138+
139+
118140
def test_index_equal_level_values_mismatch(check_exact, rtol):
119141
idx1 = MultiIndex.from_tuples([("A", 2), ("A", 2), ("B", 3), ("B", 4)])
120142
idx2 = MultiIndex.from_tuples([("A", 1), ("A", 2), ("B", 3), ("B", 4)])

0 commit comments

Comments
 (0)