Skip to content

Added test for assert_index_equal to check that function raises an exception if two different types #48351

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 6 commits into from
Sep 2, 2022
Merged
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
16 changes: 16 additions & 0 deletions pandas/tests/util/test_assert_index_equal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pytest

from pandas import (
NA,
Categorical,
CategoricalIndex,
Index,
Expand Down Expand Up @@ -238,6 +239,21 @@ def test_index_equal_range_categories(check_categorical, exact):
)


def test_assert_index_equal_different_inferred_types():
# GH#31884
msg = """\
Index are different

Attribute "inferred_type" are different
\\[left\\]: mixed
\\[right\\]: datetime"""

idx1 = Index([NA, np.datetime64("nat")])
idx2 = Index([NA, NaT])
with pytest.raises(AssertionError, match=msg):
tm.assert_index_equal(idx1, idx2)


def test_assert_index_equal_different_names_check_order_false():
# GH#47328
idx1 = Index([1, 3], name="a")
Expand Down