From a84714038baad57c78281508fc22048f03c41a7c Mon Sep 17 00:00:00 2001 From: Anton Shevtsov Date: Thu, 1 Sep 2022 23:14:47 +0300 Subject: [PATCH 1/3] added test for `assert_index_equal` function --- doc/source/whatsnew/v1.5.0.rst | 1 + pandas/tests/util/test_assert_index_equal.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/doc/source/whatsnew/v1.5.0.rst b/doc/source/whatsnew/v1.5.0.rst index 8671b73526f80..ff9f3f15e7bba 100644 --- a/doc/source/whatsnew/v1.5.0.rst +++ b/doc/source/whatsnew/v1.5.0.rst @@ -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`) diff --git a/pandas/tests/util/test_assert_index_equal.py b/pandas/tests/util/test_assert_index_equal.py index 1fa7b979070a7..90feeac401587 100644 --- a/pandas/tests/util/test_assert_index_equal.py +++ b/pandas/tests/util/test_assert_index_equal.py @@ -6,6 +6,7 @@ CategoricalIndex, Index, MultiIndex, + NA, NaT, RangeIndex, ) @@ -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") From 992f4d8e1c0f6f2b976dfc11aeea258fbb75719e Mon Sep 17 00:00:00 2001 From: Anton Shevtsov Date: Thu, 1 Sep 2022 23:26:25 +0300 Subject: [PATCH 2/3] added test for `assert_index_equal` function --- pandas/tests/util/test_assert_index_equal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/util/test_assert_index_equal.py b/pandas/tests/util/test_assert_index_equal.py index 90feeac401587..0b2c2e12a2d2a 100644 --- a/pandas/tests/util/test_assert_index_equal.py +++ b/pandas/tests/util/test_assert_index_equal.py @@ -2,11 +2,11 @@ import pytest from pandas import ( + NA, Categorical, CategoricalIndex, Index, MultiIndex, - NA, NaT, RangeIndex, ) From 0a177ab35355a129680fe7ad003152c2fd37d250 Mon Sep 17 00:00:00 2001 From: Anton Shevtsov Date: Fri, 2 Sep 2022 20:34:44 +0300 Subject: [PATCH 3/3] added test for `assert_index_equal` function --- doc/source/whatsnew/v1.5.0.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/source/whatsnew/v1.5.0.rst b/doc/source/whatsnew/v1.5.0.rst index ff9f3f15e7bba..8671b73526f80 100644 --- a/doc/source/whatsnew/v1.5.0.rst +++ b/doc/source/whatsnew/v1.5.0.rst @@ -319,7 +319,6 @@ 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`)