Skip to content

DEPR/REGR: Fix pandas.util.testing deprecation #30745

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 4 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
21 changes: 14 additions & 7 deletions pandas/tests/api/test_api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from typing import List

import pandas as pd
Expand Down Expand Up @@ -288,14 +289,20 @@ def test_testing(self):
self.check(testing, self.funcs)

def test_util_testing_deprecated(self):
s = pd.Series([], dtype="object")
with tm.assert_produces_warning(FutureWarning) as m:
import pandas.util.testing as tm2
# avoid cache state affecting the test
sys.modules.pop("pandas.util.testing", None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in theory this should be in a context manager (but nbd)


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

assert "pandas.testing.assert_series_equal" in str(m[0].message)
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:
tm2.DataFrame
assert "removed" in str(m[0].message)
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)
1 change: 0 additions & 1 deletion pandas/util/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from pandas.util._decorators import Appender, Substitution, cache_readonly # noqa

from pandas.core.util.hashing import hash_array, hash_pandas_object # noqa
from pandas.util.testing import testing # noqa: F401
12 changes: 12 additions & 0 deletions pandas/util/testing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import warnings

from pandas._testing import * # noqa

warnings.warn(
(
"pandas.util.testing is deprecated. Use the functions in the "
"public API at pandas.testing instead."
),
FutureWarning,
stacklevel=2,
)
144 changes: 0 additions & 144 deletions pandas/util/testing/__init__.py

This file was deleted.