Skip to content

Commit

Permalink
Fix tests and warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
ryankarlos committed Dec 26, 2019
1 parent 38ee7ce commit 0dd69b7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
12 changes: 6 additions & 6 deletions pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ class Panel:

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

def __getattr__(self, item):
self.warnings.warn(
"The pandas.datetime module is deprecated and will be "
"removed from pandas in a future version. Import numpy "
"directly instead",
"The pandas.datetime module is deprecated "
"and will be removed from pandas in a future version. "
"Import datetime directly instead.",
FutureWarning,
stacklevel=2,
)
Expand Down
9 changes: 6 additions & 3 deletions pandas/tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,13 @@ def test_api(self):

def test_datetime():
from datetime import datetime
import warnings
import pytest

with warnings.catch_warnings():
warnings.simplefilter("ignore", FutureWarning)
msg = "The pandas.datetime module is deprecated " \
"and will be removed from pandas in a future version. " \
"Import datetime directly instead."

with pytest.warns(FutureWarning, match=msg):
assert datetime(2015, 1, 2, 0, 0) == pd.datetime(2015, 1, 2, 0, 0)


Expand Down

0 comments on commit 0dd69b7

Please sign in to comment.