summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_calendar.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-11-26 07:57:57 (GMT)
committerGeorg Brandl <georg@python.org>2010-11-26 07:57:57 (GMT)
commit79f096a7aab611b6299c0944d6ab2e9552e6caca (patch)
tree867f18e0860374fc3dbbbebf432fd712d9aaf043 /Lib/test/test_calendar.py
parentb8d0e365e206328557a45f937a23844929427ffb (diff)
downloadcpython-79f096a7aab611b6299c0944d6ab2e9552e6caca.zip
cpython-79f096a7aab611b6299c0944d6ab2e9552e6caca.tar.gz
cpython-79f096a7aab611b6299c0944d6ab2e9552e6caca.tar.bz2
Merged revisions 85728 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r85728 | georg.brandl | 2010-10-19 20:54:25 +0200 (Di, 19 Okt 2010) | 1 line #10092: Properly reset locale in Locale*Calendar classes. The context manager was buggy because setlocale() returns the *new* locale, not the old. Also add a test for this. ........
Diffstat (limited to 'Lib/test/test_calendar.py')
-rw-r--r--Lib/test/test_calendar.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py
index fad517c..8396bdf 100644
--- a/Lib/test/test_calendar.py
+++ b/Lib/test/test_calendar.py
@@ -2,6 +2,7 @@ import calendar
import unittest
from test import test_support
+import locale
result_2004_text = """
@@ -248,6 +249,22 @@ class CalendarTestCase(unittest.TestCase):
# verify it "acts like a sequence" in two forms of iteration
self.assertEqual(value[::-1], list(reversed(value)))
+ def test_localecalendars(self):
+ # ensure that Locale{Text,HTML}Calendar resets the locale properly
+ # (it is still not thread-safe though)
+ try:
+ def_locale = locale.getdefaultlocale()
+ except locale.Error:
+ # cannot determine a default locale -- skip test
+ return
+ old_october = calendar.TextCalendar().formatmonthname(2010, 10, 10)
+ calendar.LocaleTextCalendar(
+ locale=def_locale).formatmonthname(2010, 10, 10)
+ calendar.LocaleHTMLCalendar(
+ locale=def_locale).formatmonthname(2010, 10)
+ new_october = calendar.TextCalendar().formatmonthname(2010, 10, 10)
+ self.assertEquals(old_october, new_october)
+
class MonthCalendarTestCase(unittest.TestCase):
def setUp(self):