summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/calendar.py4
-rw-r--r--Lib/test/test_calendar.py14
-rw-r--r--Lib/test/test_rlcompleter.py4
3 files changed, 18 insertions, 4 deletions
diff --git a/Lib/calendar.py b/Lib/calendar.py
index 12bd1a8..84aa3a4 100644
--- a/Lib/calendar.py
+++ b/Lib/calendar.py
@@ -486,8 +486,8 @@ class different_locale:
self.locale = locale
def __enter__(self):
- self.oldlocale = _locale.setlocale(_locale.LC_TIME, self.locale)
- #return _locale.getlocale(_locale.LC_TIME)[1]
+ self.oldlocale = _locale.getlocale(_locale.LC_TIME)
+ _locale.setlocale(_locale.LC_TIME, self.locale)
def __exit__(self, *args):
_locale.setlocale(_locale.LC_TIME, self.oldlocale)
diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py
index e8b2ca5..a4839a6 100644
--- a/Lib/test/test_calendar.py
+++ b/Lib/test/test_calendar.py
@@ -2,6 +2,7 @@ import calendar
import unittest
from test import support
+import locale
result_2004_text = """
@@ -250,6 +251,19 @@ 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)
+ old_october = calendar.TextCalendar().formatmonthname(2010, 10, 10)
+ try:
+ calendar.LocaleTextCalendar(locale='').formatmonthname(2010, 10, 10)
+ except locale.Error:
+ # cannot set the system default locale -- skip rest of test
+ return
+ calendar.LocaleHTMLCalendar(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):
diff --git a/Lib/test/test_rlcompleter.py b/Lib/test/test_rlcompleter.py
index 29e6a1b..11a7bd2 100644
--- a/Lib/test/test_rlcompleter.py
+++ b/Lib/test/test_rlcompleter.py
@@ -31,9 +31,9 @@ class TestRlcompleter(unittest.TestCase):
def test_global_matches(self):
# test with builtins namespace
- self.assertEqual(self.stdcompleter.global_matches('di'),
+ self.assertEqual(sorted(self.stdcompleter.global_matches('di')),
[x+'(' for x in dir(builtins) if x.startswith('di')])
- self.assertEqual(self.stdcompleter.global_matches('st'),
+ self.assertEqual(sorted(self.stdcompleter.global_matches('st')),
[x+'(' for x in dir(builtins) if x.startswith('st')])
self.assertEqual(self.stdcompleter.global_matches('akaksajadhak'), [])