Skip to content

Commit 8803056

Browse files
TomAugspurgerjreback
authored andcommitted
DEPR/REGR: Fix pandas.util.testing deprecation (#30745)
1 parent b1e77f9 commit 8803056

File tree

4 files changed

+26
-152
lines changed

4 files changed

+26
-152
lines changed

pandas/tests/api/test_api.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from typing import List
23

34
import pandas as pd
@@ -288,14 +289,20 @@ def test_testing(self):
288289
self.check(testing, self.funcs)
289290

290291
def test_util_testing_deprecated(self):
291-
s = pd.Series([], dtype="object")
292-
with tm.assert_produces_warning(FutureWarning) as m:
293-
import pandas.util.testing as tm2
292+
# avoid cache state affecting the test
293+
sys.modules.pop("pandas.util.testing", None)
294294

295-
tm2.assert_series_equal(s, s)
295+
with tm.assert_produces_warning(FutureWarning) as m:
296+
import pandas.util.testing # noqa: F401
296297

297-
assert "pandas.testing.assert_series_equal" in str(m[0].message)
298+
assert "pandas.util.testing is deprecated" in str(m[0].message)
299+
assert "pandas.testing instead" in str(m[0].message)
298300

301+
def test_util_testing_deprecated_direct(self):
302+
# avoid cache state affecting the test
303+
sys.modules.pop("pandas.util.testing", None)
299304
with tm.assert_produces_warning(FutureWarning) as m:
300-
tm2.DataFrame
301-
assert "removed" in str(m[0].message)
305+
from pandas.util.testing import assert_series_equal # noqa: F401
306+
307+
assert "pandas.util.testing is deprecated" in str(m[0].message)
308+
assert "pandas.testing instead" in str(m[0].message)

pandas/util/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
from pandas.util._decorators import Appender, Substitution, cache_readonly # noqa
22

33
from pandas.core.util.hashing import hash_array, hash_pandas_object # noqa
4-
from pandas.util.testing import testing # noqa: F401

pandas/util/testing.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import warnings
2+
3+
from pandas._testing import * # noqa
4+
5+
warnings.warn(
6+
(
7+
"pandas.util.testing is deprecated. Use the functions in the "
8+
"public API at pandas.testing instead."
9+
),
10+
FutureWarning,
11+
stacklevel=2,
12+
)

pandas/util/testing/__init__.py

Lines changed: 0 additions & 144 deletions
This file was deleted.

0 commit comments

Comments
 (0)