[Python-checkins] cpython (merge 3.3 -> default): Added test to ensure localized calendar methods return strings and not bytes.
serhiy.storchaka
python-checkins at python.org
Thu Jan 31 15:03:14 CET 2013
http://hg.python.org/cpython/rev/e460dedf8633
changeset: 81854:e460dedf8633
parent: 81850:e406b8bd7b38
parent: 81853:5bad2c422315
user: Serhiy Storchaka <storchaka at gmail.com>
date: Thu Jan 31 16:01:46 2013 +0200
summary:
Added test to ensure localized calendar methods return strings and not bytes.
files:
Lib/test/test_calendar.py | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py
--- a/Lib/test/test_calendar.py
+++ b/Lib/test/test_calendar.py
@@ -457,11 +457,21 @@
# (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)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list