summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-01-31 14:01:46 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-01-31 14:01:46 (GMT)
commitf22ba81748f243fb6cdd55728500cc4a34149e0a (patch)
treeda71b4616dd7c0789d45849fb99be276c481e032
parentdb58e15ee55c66fd4900be2ab2e02b864ae2313e (diff)
parentcc9e5369d37f91daf36df451b797d42630de839f (diff)
downloadcpython-f22ba81748f243fb6cdd55728500cc4a34149e0a.zip
cpython-f22ba81748f243fb6cdd55728500cc4a34149e0a.tar.gz
cpython-f22ba81748f243fb6cdd55728500cc4a34149e0a.tar.bz2
Added test to ensure localized calendar methods return strings and not bytes.
-rw-r--r--Lib/test/test_calendar.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py
index e594e01..8adf5bd 100644
--- a/Lib/test/test_calendar.py
+++ b/Lib/test/test_calendar.py
@@ -457,11 +457,21 @@ 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')
+ self.assertIsInstance(local_weekday, str)
+ self.assertIsInstance(local_month, str)
+ 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)
+ self.assertIsInstance(local_weekday, str)
+ self.assertIsInstance(local_month, str)
new_october = calendar.TextCalendar().formatmonthname(2010, 10, 10)
self.assertEqual(old_october, new_october)