Skip to content

Commit f36b1fb

Browse files
committed
TST: Add tests for CategoricalIndex mismatch scenarios
1 parent ecaeb64 commit f36b1fb

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

pandas/tests/util/test_assert_index_equal.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def test_assert_multi_index_dtype_check_categorical(check_categorical):
320320

321321

322322
def test_assert_index_equal_categorical_mismatch_categories():
323-
# GH#61941
323+
# GH#61941 - CategoricalIndex vs Index
324324
ci = CategoricalIndex(["a", "b", "c"], categories=["a", "b", "c"], ordered=False)
325325
idx = Index(["a", "b", "c"])
326326

@@ -329,3 +329,15 @@ def test_assert_index_equal_categorical_mismatch_categories():
329329
ci,
330330
idx,
331331
)
332+
333+
334+
def test_assert_categorical_index_equal_mismatch_categories():
335+
# GH#61941 - both left and right are CategoricalIndex
336+
ci1 = CategoricalIndex(["a", "b", "c"], categories=["a", "b", "c"], ordered=False)
337+
ci2 = CategoricalIndex(["a", "b", "c"], categories=["a", "b", "d"], ordered=False)
338+
339+
with pytest.raises(AssertionError, match="Index are different"):
340+
tm.assert_index_equal(
341+
ci1,
342+
ci2,
343+
)

0 commit comments

Comments
 (0)