[Zope-Checkins] CVS: Zope3/lib/python/Zope/I18n/tests - testDirectives.py:1.3

Barry Warsaw barry@wooz.org
Tue, 18 Jun 2002 14:23:29 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/I18n/tests
In directory cvs.zope.org:/tmp/cvs-serv3633/lib/python/Zope/I18n/tests

Modified Files:
	testDirectives.py 
Log Message:
testDefaultLanguages(): Add a test of the gts:defaultLanguages
directive, and some refactoring of the existing tests.


=== Zope3/lib/python/Zope/I18n/tests/testDirectives.py 1.2 => 1.3 ===
 from Zope.Configuration.Exceptions import ConfigurationError
 from Zope.ComponentArchitecture.tests.PlacelessSetup import PlacelessSetup
-
+from Zope.I18n.GlobalTranslationService import translationService 
 
 import Zope.I18n
 defs_path = os.path.join(os.path.split(Zope.I18n.__file__)[0],
@@ -47,21 +47,28 @@
 
 
     def testRegisterTranslations(self):
-        from Zope.I18n.GlobalTranslationService import translationService 
-             
-        self.assertEqual(translationService._catalogs, {})
-
-        from Zope.I18n import tests
+        eq = self.assertEqual
+        eq(translationService._catalogs, {})
         xmlconfig(StringIO(template % (
             '''
             <gts:registerTranslations directory="./locale" />
             '''
-            )), None, Context([], tests)) 
-
-        path = os.path.join(Context([], tests).path(), 'locale', 'en',
+            )), None, Context([], Zope.I18n.tests)) 
+        path = os.path.join(Context([], Zope.I18n.tests).path(),
+                            'locale', 'en',
                             'LC_MESSAGES', 'Zope-I18n.mo')
-        self.assertEqual(translationService._catalogs,
-                         {('en', 'Zope-I18n'): [unicode(path)]})
+        eq(translationService._catalogs,
+           {('en', 'Zope-I18n'): [unicode(path)]})
+
+    def testDefaultLanguages(self):
+        eq = self.assertEqual
+        eq(translationService._fallbacks, ['en'])
+        xmlconfig(StringIO(template % (
+            '''
+            <gts:defaultLanguages languages="de nl xx" />
+            '''
+            )), None, Context([], Zope.I18n.tests))
+        eq(translationService._fallbacks, ['de', 'nl', 'xx'])
 
 
 def test_suite():