Skip to content

Commit 32af092

Browse files
committed
Fix tests
1 parent 38ee7ce commit 32af092

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

pandas/__init__.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ class Panel:
212212

213213
elif name == "datetime":
214214
warnings.warn(
215-
"The datetime class is removed from pandas. Accessing it from "
216-
"the top-level namespace will also be removed in the next "
217-
"version",
215+
"The pandas.datetime module is deprecated "
216+
"and will be removed from pandas in a future version. "
217+
"Import datetime directly instead.",
218218
FutureWarning,
219219
stacklevel=2,
220220
)
@@ -257,9 +257,9 @@ def __init__(self):
257257

258258
def __getattr__(self, item):
259259
self.warnings.warn(
260-
"The pandas.datetime module is deprecated and will be "
261-
"removed from pandas in a future version. Import numpy "
262-
"directly instead",
260+
"The pandas.datetime module is deprecated "
261+
"and will be removed from pandas in a future version. "
262+
"Import datetime directly instead.",
263263
FutureWarning,
264264
stacklevel=2,
265265
)

pandas/tests/api/test_api.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,14 @@ def test_datetime():
226226
from datetime import datetime
227227
import warnings
228228

229-
with warnings.catch_warnings():
230-
warnings.simplefilter("ignore", FutureWarning)
229+
msg = "The pandas.datetime module is deprecated " \
230+
"and will be removed from pandas in a future version. " \
231+
"Import datetime directly instead."
232+
233+
with warnings.catch_warnings(record=True) as w:
231234
assert datetime(2015, 1, 2, 0, 0) == pd.datetime(2015, 1, 2, 0, 0)
235+
assert issubclass(w[-1].category, FutureWarning)
236+
assert msg in str(w[-1].message)
232237

233238

234239
class TestApi(Base):

0 commit comments

Comments
 (0)