[Checkins] SVN: zope.app.locales/trunk/src/zope/app/locales/tests.py adding test code for charset in Message catalog

Manabu Terada terada at cmscom.jp
Wed Mar 24 06:47:35 EDT 2010


Log message for revision 110158:
  adding test code for charset in Message catalog

Changed:
  U   zope.app.locales/trunk/src/zope/app/locales/tests.py

-=-
Modified: zope.app.locales/trunk/src/zope/app/locales/tests.py
===================================================================
--- zope.app.locales/trunk/src/zope/app/locales/tests.py	2010-03-24 09:39:38 UTC (rev 110157)
+++ zope.app.locales/trunk/src/zope/app/locales/tests.py	2010-03-24 10:47:35 UTC (rev 110158)
@@ -15,14 +15,42 @@
 
 $Id$
 """
+import os
 import doctest
 import unittest
 from zope.testing.doctest import DocTestSuite
 
+class TestIsUnicodeInAllCatalog(unittest.TestCase):
+    """
+    """
+    def setUp(self):
+        pass
+    
+    def test_is_unicode(self):
+        from zope.i18n.gettextmessagecatalog import GettextMessageCatalog
+        path = os.path.dirname(__file__)
+        langs = os.listdir(path)
+        for lang in langs:
+            lc_path = os.path.join(path, lang, 'LC_MESSAGES')
+            if os.path.isdir(lc_path):
+                files = os.listdir(lc_path)
+                for f in files:
+                    if f.endswith('.mo'):
+                        mcatalog = GettextMessageCatalog(lang, 'zope',
+                                           os.path.join(lc_path, f))
+                        catalog = mcatalog._catalog
+                        self.failUnless(catalog._charset, 
+            u"""Charset value for the Message catalog is missing. 
+                The language is %s (zope.po). 
+                Value of the message catalog should be in unicode""" % (lang,)
+                                        )
+
+
 def test_suite():
     return unittest.TestSuite((
         DocTestSuite('zope.app.locales.extract',
             optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,),
+        unittest.makeSuite(TestIsUnicodeInAllCatalog),
         ))
 
 if __name__ == '__main__':



More information about the checkins mailing list