[Zope3-checkins] SVN: Zope3/trunk/src/zope/i18n/ Implemented a test to ensure that the root locale get loaded correctly and

Stephan Richter srichter at cosmos.phy.tufts.edu
Tue Feb 15 01:07:28 EST 2005


Log message for revision 29146:
  Implemented a test to ensure that the root locale get loaded correctly and 
  actually fix a formatter bug.
  
  

Changed:
  U   Zope3/trunk/src/zope/i18n/format.py
  U   Zope3/trunk/src/zope/i18n/locales/tests/test_locales.py

-=-
Modified: Zope3/trunk/src/zope/i18n/format.py
===================================================================
--- Zope3/trunk/src/zope/i18n/format.py	2005-02-15 05:34:57 UTC (rev 29145)
+++ Zope3/trunk/src/zope/i18n/format.py	2005-02-15 06:07:28 UTC (rev 29146)
@@ -559,8 +559,8 @@
         ('d', 2): "%.2i" %dt.day,
         ('E', 1): str(weekday),
         ('E', 2): "%.2i" %weekday,
-        ('E', 3): calendar.days[weekday][1],
-        ('E', 4): calendar.days[weekday][0],
+        ('E', 3): calendar.days[dt.weekday() + 1][1],
+        ('E', 4): calendar.days[dt.weekday() + 1][0],
         ('D', 1): dt.strftime('%j'),
         ('w', 1): dt.strftime('%W'),
         ('w', 2): dt.strftime('%.2W'),

Modified: Zope3/trunk/src/zope/i18n/locales/tests/test_locales.py
===================================================================
--- Zope3/trunk/src/zope/i18n/locales/tests/test_locales.py	2005-02-15 05:34:57 UTC (rev 29145)
+++ Zope3/trunk/src/zope/i18n/locales/tests/test_locales.py	2005-02-15 06:07:28 UTC (rev 29146)
@@ -140,12 +140,31 @@
         self.assertEqual(locale.id.territory, 'GB')
         self.assertEqual(locale.id.variant, None)
 
+class TestRootLocale(TestCase):
+    """There were some complaints that the root locale does not work
+    correctly, so make sure it does."""
 
+    locales.loadLocale(None, None, None)
+    locale = locales.getLocale(None, None, None)
+
+    def test_dateFormatter(self):
+        formatter = self.locale.dates.getFormatter('date')
+        self.assertEqual(
+            formatter.format(datetime.date(2004, 10, 31), 'E'), '1')
+        self.assertEqual(
+            formatter.format(datetime.date(2004, 10, 31), 'EE'), '01')
+        self.assertEqual(
+            formatter.format(datetime.date(2004, 10, 31), 'EEE'), '1')
+        self.assertEqual(
+            formatter.format(datetime.date(2004, 10, 31), 'EEEE'), '1')
+    
+
 def test_suite():
     return TestSuite((
         makeSuite(TestLocaleProvider),
         makeSuite(TestLocaleAndProvider),
         makeSuite(TestGlobalLocaleProvider),
+        makeSuite(TestRootLocale),
         ))
 
 if __name__ == "__main__":



More information about the Zope3-Checkins mailing list