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
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.5.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ Other enhancements
- ``times`` argument in :class:`.ExponentialMovingWindow` now accepts ``np.timedelta64`` (:issue:`47003`)
- :class:`.DataError`, :class:`.SpecificationError`, :class:`.SettingWithCopyError`, :class:`.SettingWithCopyWarning`, :class:`.NumExprClobberingError`, :class:`.UndefinedVariableError`, :class:`.IndexingError`, :class:`.PyperclipException`, :class:`.PyperclipWindowsException`, :class:`.CSSWarning`, :class:`.PossibleDataLossError`, :class:`.ClosedFileError`, :class:`.IncompatibilityWarning`, :class:`.AttributeConflictWarning`, :class:`.DatabaseError`, :class:`.PossiblePrecisionLoss`, :class:`.ValueLabelTypeMismatch`, :class:`.InvalidColumnName`, and :class:`.CategoricalConversionWarning` are now exposed in ``pandas.errors`` (:issue:`27656`)
- Added ``check_like`` argument to :func:`testing.assert_series_equal` (:issue:`47247`)
- Added unit test to test that the :func:`testing.assert_index_equal` raises an exception if two different types (:issue:`31884`)
- Add support for :meth:`.GroupBy.ohlc` for extension array dtypes (:issue:`37493`)
- Allow reading compressed SAS files with :func:`read_sas` (e.g., ``.sas7bdat.gz`` files)
- :func:`pandas.read_html` now supports extracting links from table cells (:issue:`13141`)
Expand Down
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