From 0038bad877f64d8c4976e4db612d3942982ca51e Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Tue, 6 Mar 2018 04:25:55 -0800 Subject: [PATCH] month_name/day_name warnings followup (#20010) --- pandas/_libs/tslibs/timestamps.pyx | 2 +- pandas/tests/indexes/datetimes/test_misc.py | 4 +++- pandas/tests/indexes/datetimes/test_scalar_compat.py | 7 ++++++- pandas/tests/scalar/timestamp/test_timestamp.py | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index 5bb53cf20b478..9818d53e386bd 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -766,7 +766,7 @@ class Timestamp(_Timestamp): """ warnings.warn("`weekday_name` is deprecated and will be removed in a " "future version. Use `day_name` instead", - DeprecationWarning) + FutureWarning) return self.day_name() @property diff --git a/pandas/tests/indexes/datetimes/test_misc.py b/pandas/tests/indexes/datetimes/test_misc.py index a65b80efc7911..056924f2c6663 100644 --- a/pandas/tests/indexes/datetimes/test_misc.py +++ b/pandas/tests/indexes/datetimes/test_misc.py @@ -271,7 +271,9 @@ def test_datetime_name_accessors(self, time_locale): assert dti.weekday_name[day] == eng_name assert dti.day_name(locale=time_locale)[day] == name ts = Timestamp(datetime(2016, 4, day)) - assert ts.weekday_name == eng_name + with tm.assert_produces_warning(FutureWarning, + check_stacklevel=False): + assert ts.weekday_name == eng_name assert ts.day_name(locale=time_locale) == name dti = dti.append(DatetimeIndex([pd.NaT])) assert np.isnan(dti.day_name(locale=time_locale)[-1]) diff --git a/pandas/tests/indexes/datetimes/test_scalar_compat.py b/pandas/tests/indexes/datetimes/test_scalar_compat.py index 6f0756949edc6..9180bb0af3af3 100644 --- a/pandas/tests/indexes/datetimes/test_scalar_compat.py +++ b/pandas/tests/indexes/datetimes/test_scalar_compat.py @@ -47,7 +47,12 @@ def test_dti_timestamp_fields(self, field): # extra fields from DatetimeIndex like quarter and week idx = tm.makeDateIndex(100) expected = getattr(idx, field)[-1] - result = getattr(Timestamp(idx[-1]), field) + if field == 'weekday_name': + with tm.assert_produces_warning(FutureWarning, + check_stacklevel=False): + result = getattr(Timestamp(idx[-1]), field) + else: + result = getattr(Timestamp(idx[-1]), field) assert result == expected def test_dti_timestamp_freq_fields(self): diff --git a/pandas/tests/scalar/timestamp/test_timestamp.py b/pandas/tests/scalar/timestamp/test_timestamp.py index 0acf7acb19c0d..cde5baf47c18e 100644 --- a/pandas/tests/scalar/timestamp/test_timestamp.py +++ b/pandas/tests/scalar/timestamp/test_timestamp.py @@ -105,7 +105,7 @@ def check(value, equal): def test_names(self, data, time_locale): # GH 17354 # Test .weekday_name, .day_name(), .month_name - with tm.assert_produces_warning(DeprecationWarning, + with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): assert data.weekday_name == 'Monday' if time_locale is None: