Skip to content

Commit 0dd69b7

Browse files
committed
Fix tests and warning message
1 parent 38ee7ce commit 0dd69b7

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
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

+6-3
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,13 @@ def test_api(self):
224224

225225
def test_datetime():
226226
from datetime import datetime
227-
import warnings
227+
import pytest
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 pytest.warns(FutureWarning, match=msg):
231234
assert datetime(2015, 1, 2, 0, 0) == pd.datetime(2015, 1, 2, 0, 0)
232235

233236

0 commit comments

Comments
 (0)