[Zope3-checkins] CVS: Zope3/src/zope/i18n/tests - test_formats.py:1.7 test_locales.py:1.5 test_xmllocales.py:1.5

Stephan Richter srichter@cbu.edu
Tue, 25 Mar 2003 09:48:33 -0500


Update of /cvs-repository/Zope3/src/zope/i18n/tests
In directory cvs.zope.org:/tmp/cvs-serv21541/src/zope/i18n/tests

Modified Files:
	test_formats.py test_locales.py test_xmllocales.py 
Log Message:
Rworked the Locale-related interfaces to be much simpler and attribute 
oriented. Fixed implementation and tests. 

Note: There are fewer tests than before, since a lot of accessor and 
      mutator methods are missing.

Pairing at PyCon Sprint: Trevor and Stephan


=== Zope3/src/zope/i18n/tests/test_formats.py 1.6 => 1.7 ===
--- Zope3/src/zope/i18n/tests/test_formats.py:1.6	Thu Mar 13 13:49:14 2003
+++ Zope3/src/zope/i18n/tests/test_formats.py	Tue Mar 25 09:48:02 2003
@@ -28,7 +28,7 @@
 from zope.i18n.format import NumberFormat
 from zope.i18n.format import parseNumberPattern
 
-from zope.i18n.locales import ICUXMLLocaleFactory
+from zope.i18n.locales import XMLLocaleFactory
 
 from zope.i18n import tests
 testdir = os.path.dirname(tests.__file__)
@@ -134,7 +134,7 @@
     """
 
     path = os.path.join(testdir, 'xmllocales', 'de.xml')
-    locale = ICUXMLLocaleFactory(path)()
+    locale = XMLLocaleFactory(path)()
     info = buildDateTimeParseInfo(locale.getDefaultCalendar())
 
     def testEra(self):
@@ -166,7 +166,7 @@
     interface."""
 
     path = os.path.join(testdir, 'xmllocales', 'de.xml')
-    locale = ICUXMLLocaleFactory(path)()
+    locale = XMLLocaleFactory(path)()
     format = DateTimeFormat(calendar=locale.getDefaultCalendar())
 
     def testInterfaceConformity(self):
@@ -460,9 +460,9 @@
     """Test the functionality of an implmentation of the NumberFormat."""
 
     path = os.path.join(testdir, 'xmllocales', 'de_DE.xml')
-    locale = ICUXMLLocaleFactory(path)()
+    locale = XMLLocaleFactory(path)()
     format = NumberFormat(
-            symbols=locale.getDefaultNumberFormat().getSymbolMap())
+            symbols=locale.getDefaultNumberFormat().symbols)
 
     def testInterfaceConformity(self):
         self.assert_(INumberFormat.isImplementedBy(self.format))


=== Zope3/src/zope/i18n/tests/test_locales.py 1.4 => 1.5 === (531/631 lines abridged)
--- Zope3/src/zope/i18n/tests/test_locales.py:1.4	Thu Mar 13 13:49:14 2003
+++ Zope3/src/zope/i18n/tests/test_locales.py	Tue Mar 25 09:48:02 2003
@@ -25,11 +25,11 @@
 from zope.i18n.interfaces import ILocaleNumberFormat, ILocaleCurrency
 
 from zope.i18n.locales import NoGeneralLocaleError, LoadLocaleError
-from zope.i18n.locales import LocaleProvider, ICULocale, ICUXMLLocaleFactory
+from zope.i18n.locales import LocaleProvider, Locale, XMLLocaleFactory
 from zope.i18n.locales import locales
-from zope.i18n.locales import ICULocaleVersion, ICULocaleIdentity
-from zope.i18n.locales import ICULocaleTimeZone, ICULocaleCalendar
-from zope.i18n.locales import ICULocaleNumberFormat, ICULocaleCurrency
+from zope.i18n.locales import LocaleVersion, LocaleIdentity
+from zope.i18n.locales import LocaleTimeZone, LocaleCalendar
+from zope.i18n.locales import LocaleNumberFormat, LocaleCurrency
 
 from zope.i18n import tests
 testdir = os.path.dirname(tests.__file__)
@@ -49,24 +49,24 @@
 
     def test_getLocale(self):
         locale = self.locales.getLocale(None, None, None)
-        self.assertEqual(locale.id.getLanguage(), None)
-        self.assertEqual(locale.id.getCountry(), None)
-        self.assertEqual(locale.id.getVariant(), None)
+        self.assertEqual(locale.id.language, None)
+        self.assertEqual(locale.id.country, None)
+        self.assertEqual(locale.id.variant, None)
 
         locale = self.locales.getLocale('de', None, None)
-        self.assertEqual(locale.id.getLanguage(), 'de')
-        self.assertEqual(locale.id.getCountry(), None)
-        self.assertEqual(locale.id.getVariant(), None)
+        self.assertEqual(locale.id.language, 'de')
+        self.assertEqual(locale.id.country, None)
+        self.assertEqual(locale.id.variant, None)
 
         locale = self.locales.getLocale('de', 'DE', None)
-        self.assertEqual(locale.id.getLanguage(), 'de')
-        self.assertEqual(locale.id.getCountry(), 'DE')
-        self.assertEqual(locale.id.getVariant(), None)
+        self.assertEqual(locale.id.language, 'de')
+        self.assertEqual(locale.id.country, 'DE')
+        self.assertEqual(locale.id.variant, None)
 
         locale = self.locales.getLocale('de', 'DE', 'PREEURO')
-        self.assertEqual(locale.id.getLanguage(), 'de')
-        self.assertEqual(locale.id.getCountry(), 'DE')
-        self.assertEqual(locale.id.getVariant(), 'PREEURO')
+        self.assertEqual(locale.id.language, 'de')

[-=- -=- -=- 531 lines omitted -=- -=- -=-]

-
     def test_getDefaultCurrency(self):
         curr = self.locale.getDefaultCurrency()
         self.assertEqual(curr.id, u'XXX')
 
-    def test_getCurrencyIds(self):
-        ids = self.locale.getCurrencyIds()
-        self.assertEqual(ids, [u'XXX'])
-
 
-class TestICULocaleAndProvider(TestCase):
+class TestLocaleAndProvider(TestCase):
 
     # Set the locale on the class so that test cases don't have
     # to pay to construct a new one each time.
@@ -668,22 +439,22 @@
 
     def test_getLocale(self):
         locale = locales.getLocale('de', 'AT')
-        self.assertEqual(locale.id.getLanguage(), 'de')
-        self.assertEqual(locale.id.getCountry(), 'AT')
-        self.assertEqual(locale.id.getVariant(), None)
+        self.assertEqual(locale.id.language, 'de')
+        self.assertEqual(locale.id.country, 'AT')
+        self.assertEqual(locale.id.variant, None)
 
 
 def test_suite():
     return TestSuite((
         makeSuite(TestLocaleProvider),
-        makeSuite(TestICULocaleIdentity),
-        makeSuite(TestICULocaleVersion),
-        makeSuite(TestICULocaleTimeZone),
-        makeSuite(TestICULocaleCalendar),
-        makeSuite(TestICULocaleNumberFormat),
-        makeSuite(TestICULocaleCurrency),
-        makeSuite(TestICUXMLLocaleFactory),
-        makeSuite(TestICULocale),
-        makeSuite(TestICULocaleAndProvider),
+        makeSuite(TestLocaleIdentity),
+        makeSuite(TestLocaleVersion),
+        makeSuite(TestLocaleTimeZone),
+        makeSuite(TestLocaleCalendar),
+        makeSuite(TestLocaleNumberFormat),
+        makeSuite(TestLocaleCurrency),
+        makeSuite(TestXMLLocaleFactory),
+        makeSuite(TestLocale),
+        makeSuite(TestLocaleAndProvider),
         makeSuite(TestGlobalLocaleProvider),
         ))


=== Zope3/src/zope/i18n/tests/test_xmllocales.py 1.4 => 1.5 ===
--- Zope3/src/zope/i18n/tests/test_xmllocales.py:1.4	Thu Jan  9 14:20:23 2003
+++ Zope3/src/zope/i18n/tests/test_xmllocales.py	Tue Mar 25 09:48:02 2003
@@ -8,7 +8,7 @@
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
+# FOR A PARTLAR PURPOSE.
 #
 ##############################################################################
 """Testing all XML Locale functionality.
@@ -18,7 +18,7 @@
 import os
 from unittest import TestCase, TestSuite, makeSuite
 
-from zope.i18n.locales import ICUXMLLocaleFactory
+from zope.i18n.locales import XMLLocaleFactory
 from zope.i18n.format import parseDateTimePattern, parseNumberPattern
 
 class LocaleXMLFileTestCase(TestCase):
@@ -31,11 +31,11 @@
     # For unittest.
     def shortDescription(self):
         filename = os.path.split(self.__path)[-1]
-        return '%s (Test ICU XML-Locale Files)' %filename
+        return '%s (Test  XML-Locale Files)' %filename
 
     def runTest(self):
         # Loading Locale object 
-        locale = ICUXMLLocaleFactory(self.__path)()
+        locale = XMLLocaleFactory(self.__path)()
 
         # Making sure all number format patterns parse
         for klass in locale.getNumberFormatClasses():
@@ -45,11 +45,10 @@
                     parseNumberPattern(format.getPattern(id)) is not None)
 
         # Making sure all datetime patterns parse
-        for klass in locale.getCalendarClasses():
-            calendar = locale.getCalendar(klass)
-            for pattern in calendar._date_patterns.values():
+        for calendar in locale.calendars.values():
+            for pattern in calendar.datePatterns.values():
                     self.assert_(parseDateTimePattern(pattern) is not None)
-            for pattern in calendar._time_patterns.values():
+            for pattern in calendar.timePatterns.values():
                     self.assert_(parseDateTimePattern(pattern) is not None)
                     
 
@@ -65,7 +64,7 @@
     return suite
 
 # Note: These tests are disabled, just because they take a long time to run.
-#       You should run these tests if you update the aprsing code and/or
+#       You should run these tests if you update the parsing code and/or
 #       update the Locale XML Files.
 def test_suite():
-    return TestSuite()
+    return TestSuite((makeSuite(LocaleXMLFileTestCase),))