Skip to content

Commit 34a9b91

Browse files
MrShevanAnton Shevtsov
authored andcommitted
Added test for assert_index_equal to check that function raises an exception if two different types (pandas-dev#48351)
* added test for `assert_index_equal` function * added test for `assert_index_equal` function * added test for `assert_index_equal` function Co-authored-by: Anton Shevtsov <[email protected]>
1 parent 75abc6b commit 34a9b91

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pandas/tests/util/test_assert_index_equal.py

+16
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import pytest
33

44
from pandas import (
5+
NA,
56
Categorical,
67
CategoricalIndex,
78
Index,
@@ -238,6 +239,21 @@ def test_index_equal_range_categories(check_categorical, exact):
238239
)
239240

240241

242+
def test_assert_index_equal_different_inferred_types():
243+
# GH#31884
244+
msg = """\
245+
Index are different
246+
247+
Attribute "inferred_type" are different
248+
\\[left\\]: mixed
249+
\\[right\\]: datetime"""
250+
251+
idx1 = Index([NA, np.datetime64("nat")])
252+
idx2 = Index([NA, NaT])
253+
with pytest.raises(AssertionError, match=msg):
254+
tm.assert_index_equal(idx1, idx2)
255+
256+
241257
def test_assert_index_equal_different_names_check_order_false():
242258
# GH#47328
243259
idx1 = Index([1, 3], name="a")

0 commit comments

Comments
 (0)