|
4 | 4 | import pytest
|
5 | 5 | import dateutil
|
6 | 6 | import calendar
|
| 7 | +import locale |
7 | 8 | import numpy as np
|
8 | 9 |
|
9 | 10 | from dateutil.tz import tzutc
|
@@ -95,13 +96,28 @@ def check(value, equal):
|
95 | 96 | for end in ends:
|
96 | 97 | assert getattr(ts, end)
|
97 | 98 |
|
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): |
103 | 106 | # 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 |
105 | 121 |
|
106 | 122 | @pytest.mark.parametrize('tz', [None, 'UTC', 'US/Eastern', 'Asia/Tokyo'])
|
107 | 123 | def test_is_leap_year(self, tz):
|
|
0 commit comments