diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-01-31 13:57:51 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-01-31 13:57:51 (GMT) |
commit | 8d510cd6e117b4ec827e4a26947ea76971a55763 (patch) | |
tree | 926360993820093f362ae131e1738a72ce1dcc34 /Lib/test/test_calendar.py | |
parent | 0be506a5baf8b86c519e6074af43a0f91af603c6 (diff) | |
download | cpython-8d510cd6e117b4ec827e4a26947ea76971a55763.zip cpython-8d510cd6e117b4ec827e4a26947ea76971a55763.tar.gz cpython-8d510cd6e117b4ec827e4a26947ea76971a55763.tar.bz2 |
Issue #17049: Localized calendar methods now return unicode if a locale
includes an encoding and the result string contains month or weekday (was
regression from Python 2.6).
Diffstat (limited to 'Lib/test/test_calendar.py')
-rw-r--r-- | Lib/test/test_calendar.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py index 0f91d29..40fb76d 100644 --- a/Lib/test/test_calendar.py +++ b/Lib/test/test_calendar.py @@ -255,11 +255,23 @@ class CalendarTestCase(unittest.TestCase): # (it is still not thread-safe though) old_october = calendar.TextCalendar().formatmonthname(2010, 10, 10) try: - calendar.LocaleTextCalendar(locale='').formatmonthname(2010, 10, 10) + cal = calendar.LocaleTextCalendar(locale='') + local_weekday = cal.formatweekday(1, 10) + local_month = cal.formatmonthname(2010, 10, 10) except locale.Error: # cannot set the system default locale -- skip rest of test - return - calendar.LocaleHTMLCalendar(locale='').formatmonthname(2010, 10) + raise unittest.SkipTest('cannot set the system default locale') + # should be encodable + local_weekday.encode('utf-8') + local_month.encode('utf-8') + self.assertEqual(len(local_weekday), 10) + self.assertGreaterEqual(len(local_month), 10) + cal = calendar.LocaleHTMLCalendar(locale='') + local_weekday = cal.formatweekday(1) + local_month = cal.formatmonthname(2010, 10) + # should be encodable + local_weekday.encode('utf-8') + local_month.encode('utf-8') new_october = calendar.TextCalendar().formatmonthname(2010, 10, 10) self.assertEqual(old_october, new_october) |