summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Fulton <jim@zope.com>2005-10-28 20:51:06 +0000
committerJim Fulton <jim@zope.com>2005-10-28 20:51:06 +0000
commit72b004b8c08c9853bc98c770c1ca7032477e5f90 (patch)
tree763995d5b2b71a28fccecae86a1a1d36efc3f246
downloadzope-i18n-monolithic-zope3-jim-fix-test-ZopeX3-3.0.1-Zope-2.8.tar.gz
Changed the test suite to use a leval to avoid running the testsmonolithic-zope3-jim-fix-test-ZopeX3-3.0.1-Zope-2.8
normally. These tests will still be run --at 2.
-rw-r--r--locales/tests/test_xmlfactory.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/locales/tests/test_xmlfactory.py b/locales/tests/test_xmlfactory.py
new file mode 100644
index 0000000..de8780a
--- /dev/null
+++ b/locales/tests/test_xmlfactory.py
@@ -0,0 +1,64 @@
+##############################################################################
+#
+# Copyright (c) 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# 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 PARTLAR PURPOSE.
+#
+##############################################################################
+"""Testing all XML Locale functionality.
+
+$Id$
+"""
+import os
+from unittest import TestCase, TestSuite, makeSuite
+
+from zope.i18n.locales.xmlfactory import LocaleFactory
+from zope.i18n.format import parseDateTimePattern, parseNumberPattern
+import zope.i18n
+
+class LocaleXMLFileTestCase(TestCase):
+ """This test verifies that every locale XML file can be loaded."""
+
+ level = 2
+
+ def __init__(self, path):
+ self.__path = path
+ TestCase.__init__(self)
+
+ def runTest(self):
+ # Loading Locale object
+ locale = LocaleFactory(self.__path)()
+
+ # Making sure all number format patterns parse
+ for category in (u'decimal', u'scientific', u'percent', u'currency'):
+ for length in getattr(locale.numbers, category+'Formats').values():
+ for format in length.formats.values():
+ self.assert_(parseNumberPattern(format.pattern) is not None)
+
+ # Making sure all datetime patterns parse
+ for calendar in locale.dates.calendars.values():
+ for category in ('date', 'time', 'dateTime'):
+ for length in getattr(calendar, category+'Formats').values():
+ for format in length.formats.values():
+ self.assert_(
+ parseDateTimePattern(format.pattern) is not None)
+
+
+
+def test_suite():
+ suite = TestSuite()
+ locale_dir = os.path.join(os.path.dirname(zope.i18n.__file__),
+ 'locales', 'data')
+ for path in os.listdir(locale_dir):
+ if not path.endswith(".xml"):
+ continue
+ path = os.path.join(locale_dir, path)
+ case = LocaleXMLFileTestCase(path)
+ suite.addTest(case)
+ return suite