From ab52f509e34f7654d13f290aba07e01272bd84e8 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Wed, 24 Jan 2018 17:07:32 +0100 Subject: [PATCH 1/2] Add CategoricalDtype to deprecated core.categorical shim --- pandas/core/categorical.py | 1 + pandas/tests/api/test_api.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/pandas/core/categorical.py b/pandas/core/categorical.py index 17435dfc48bde..530a3ecb5f378 100644 --- a/pandas/core/categorical.py +++ b/pandas/core/categorical.py @@ -5,3 +5,4 @@ FutureWarning, stacklevel=2) from pandas.core.arrays import Categorical # noqa +from pandas.core.dtypes.dtypes import CategoricalDtype # noqa diff --git a/pandas/tests/api/test_api.py b/pandas/tests/api/test_api.py index 4a10ed6e7402c..de6dd8dfc43b8 100644 --- a/pandas/tests/api/test_api.py +++ b/pandas/tests/api/test_api.py @@ -259,3 +259,6 @@ def test_categorical_move(self): with tm.assert_produces_warning(FutureWarning): from pandas.core.categorical import Categorical # noqa + + with tm.assert_produces_warning(FutureWarning): + from pandas.core.categorical import CategoricalDtype # noqa From b7904e95effb4199e5952278abf1cb310f9823db Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Wed, 24 Jan 2018 18:47:50 +0100 Subject: [PATCH 2/2] Purge import cache before assert --- pandas/tests/api/test_api.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandas/tests/api/test_api.py b/pandas/tests/api/test_api.py index de6dd8dfc43b8..c20767b09178c 100644 --- a/pandas/tests/api/test_api.py +++ b/pandas/tests/api/test_api.py @@ -260,5 +260,7 @@ def test_categorical_move(self): with tm.assert_produces_warning(FutureWarning): from pandas.core.categorical import Categorical # noqa + sys.modules.pop("pandas.core.categorical", None) + with tm.assert_produces_warning(FutureWarning): from pandas.core.categorical import CategoricalDtype # noqa