Skip to content

Commit 3b79e2a

Browse files
committed
Rebase and adjust tests
1 parent 05dc7c1 commit 3b79e2a

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

pandas/tests/indexes/datetimes/test_misc.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,16 @@ def test_datetimeindex_accessors(self):
245245
@pytest.mark.skipif(not tm.get_locales(), reason='No available locales')
246246
@pytest.mark.parametrize('time_locale', tm.get_locales() + [None])
247247
def test_datetime_name_accessors(self, time_locale):
248-
with tm.set_locale(time_locale, locale.LC_TIME):
249-
expected_days = calendar.day_name[:]
250-
expected_months = calendar.month_name[1:]
248+
if time_locale is None:
249+
expected_days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday',
250+
'Friday', 'Saturday', 'Sunday']
251+
expected_months = ['January', 'February', 'March', 'April', 'May',
252+
'June', 'July', 'August', 'September',
253+
'October', 'November', 'December']
254+
else:
255+
with tm.set_locale(time_locale, locale.LC_TIME):
256+
expected_days = calendar.day_name[:]
257+
expected_months = calendar.month_name[1:]
251258

252259
# GH 11128
253260
dti = DatetimeIndex(freq='D', start=datetime(1998, 1, 1),

pandas/tests/scalar/timestamp/test_timestamp.py

+22-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import pytest
55
import dateutil
66
import calendar
7+
import locale
78
import numpy as np
89

910
from dateutil.tz import tzutc
@@ -95,13 +96,28 @@ def check(value, equal):
9596
for end in ends:
9697
assert getattr(ts, end)
9798

98-
@pytest.mark.parametrize('data, expected',
99-
[(Timestamp('2017-08-28 23:00:00'), 'Monday'),
100-
(Timestamp('2017-08-28 23:00:00', tz='EST'),
101-
'Monday')])
102-
def test_weekday_name(self, data, expected):
99+
# GH 12806
100+
@pytest.mark.skipif(not tm.get_locales(), reason='No available locales')
101+
@pytest.mark.parametrize('data',
102+
[Timestamp('2017-08-28 23:00:00'),
103+
Timestamp('2017-08-28 23:00:00', tz='EST')])
104+
@pytest.mark.parametrize('time_locale', tm.get_locales() + [None])
105+
def test_names(self, data, time_locale):
103106
# GH 17354
104-
assert data.weekday_name == expected
107+
# Test .weekday_name, .day_name(), .month_name
108+
with tm.assert_produces_warning(DeprecationWarning,
109+
check_stacklevel=False):
110+
assert data.weekday_name == 'Monday'
111+
if time_locale is None:
112+
expected_day = 'Monday'
113+
expected_month = 'August'
114+
else:
115+
with tm.set_locale(time_locale, locale.LC_TIME):
116+
expected_day = calendar.day_name[0].capitalize()
117+
expected_month = calendar.month_name[8].capitalize()
118+
119+
assert data.day_name(time_locale) == expected_day
120+
assert data.month_name(time_locale) == expected_month
105121

106122
@pytest.mark.parametrize('tz', [None, 'UTC', 'US/Eastern', 'Asia/Tokyo'])
107123
def test_is_leap_year(self, tz):

0 commit comments

Comments
 (0)