From 04d4387735da160b2946515708fa376656fd0ed3 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Mon, 24 Oct 2022 16:41:27 -0700 Subject: [PATCH] DEPR: Remove pandas.util.testing --- doc/source/whatsnew/v2.0.0.rst | 1 + pandas/tests/api/test_api.py | 33 --------------------------------- pandas/util/__init__.py | 9 --------- pandas/util/testing.py | 14 -------------- 4 files changed, 1 insertion(+), 56 deletions(-) delete mode 100644 pandas/util/testing.py diff --git a/doc/source/whatsnew/v2.0.0.rst b/doc/source/whatsnew/v2.0.0.rst index 1050eed40fbb4..e45ad840a9804 100644 --- a/doc/source/whatsnew/v2.0.0.rst +++ b/doc/source/whatsnew/v2.0.0.rst @@ -218,6 +218,7 @@ Removal of prior version deprecations/changes - Removed the ``truediv`` keyword from :func:`eval` (:issue:`29812`) - Removed the ``pandas.datetime`` submodule (:issue:`30489`) - Removed the ``pandas.np`` submodule (:issue:`30296`) +- Removed ``pandas.util.testing`` in favor of ``pandas.testing`` (:issue:`30745`) - Removed :meth:`Series.str.__iter__` (:issue:`28277`) - Removed ``pandas.SparseArray`` in favor of :class:`arrays.SparseArray` (:issue:`30642`) - Removed ``pandas.SparseSeries`` and ``pandas.SparseDataFrame`` (:issue:`30642`) diff --git a/pandas/tests/api/test_api.py b/pandas/tests/api/test_api.py index be704d8eb3e7e..b3a60c1fc5d37 100644 --- a/pandas/tests/api/test_api.py +++ b/pandas/tests/api/test_api.py @@ -1,8 +1,5 @@ from __future__ import annotations -import subprocess -import sys - import pytest import pandas as pd @@ -260,36 +257,6 @@ def test_testing(self): self.check(testing, self.funcs) - def test_util_testing_deprecated(self): - # avoid cache state affecting the test - sys.modules.pop("pandas.util.testing", None) - - with tm.assert_produces_warning(FutureWarning) as m: - import pandas.util.testing # noqa: F401 - - assert "pandas.util.testing is deprecated" in str(m[0].message) - assert "pandas.testing instead" in str(m[0].message) - - def test_util_testing_deprecated_direct(self): - # avoid cache state affecting the test - sys.modules.pop("pandas.util.testing", None) - with tm.assert_produces_warning(FutureWarning) as m: - from pandas.util.testing import assert_series_equal # noqa: F401 - - assert "pandas.util.testing is deprecated" in str(m[0].message) - assert "pandas.testing instead" in str(m[0].message) - def test_util_in_top_level(self): - # in a subprocess to avoid import caching issues - out = subprocess.check_output( - [ - sys.executable, - "-c", - "import pandas; pandas.util.testing.assert_series_equal", - ], - stderr=subprocess.STDOUT, - ).decode() - assert "pandas.util.testing is deprecated" in out - with pytest.raises(AttributeError, match="foo"): pd.util.foo diff --git a/pandas/util/__init__.py b/pandas/util/__init__.py index 6e6006dd28165..aa31c024fe338 100644 --- a/pandas/util/__init__.py +++ b/pandas/util/__init__.py @@ -9,12 +9,3 @@ hash_array, hash_pandas_object, ) - - -def __getattr__(name): - if name == "testing": - import pandas.util.testing - - return pandas.util.testing - else: - raise AttributeError(f"module 'pandas.util' has no attribute '{name}'") diff --git a/pandas/util/testing.py b/pandas/util/testing.py deleted file mode 100644 index db9bfc274cd78..0000000000000 --- a/pandas/util/testing.py +++ /dev/null @@ -1,14 +0,0 @@ -import warnings - -from pandas.util._exceptions import find_stack_level - -from pandas._testing import * # noqa:F401,F403,PDF014 - -warnings.warn( - ( - "pandas.util.testing is deprecated. Use the functions in the " - "public API at pandas.testing instead." - ), - FutureWarning, - stacklevel=find_stack_level(), -)