summaryrefslogtreecommitdiff
path: root/src/zope/i18n/locales/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/zope/i18n/locales/tests')
-rw-r--r--src/zope/i18n/locales/tests/test_docstrings.py19
-rw-r--r--src/zope/i18n/locales/tests/test_fallbackcollator.py13
-rw-r--r--src/zope/i18n/locales/tests/test_locales.py51
-rw-r--r--src/zope/i18n/locales/tests/test_xmlfactory.py11
4 files changed, 60 insertions, 34 deletions
diff --git a/src/zope/i18n/locales/tests/test_docstrings.py b/src/zope/i18n/locales/tests/test_docstrings.py
index fa52078..c40b691 100644
--- a/src/zope/i18n/locales/tests/test_docstrings.py
+++ b/src/zope/i18n/locales/tests/test_docstrings.py
@@ -20,8 +20,8 @@ from zope.i18n.locales.inheritance import NoParentException
from zope.i18n.testing import unicode_checker
-class LocaleInheritanceStub(AttributeInheritance):
+class LocaleInheritanceStub(AttributeInheritance):
def __init__(self, nextLocale=None):
self.__nextLocale__ = nextLocale
@@ -32,11 +32,18 @@ class LocaleInheritanceStub(AttributeInheritance):
def test_suite():
- return unittest.TestSuite((
- DocTestSuite('zope.i18n.locales', checker=unicode_checker),
- DocTestSuite('zope.i18n.locales.inheritance', checker=unicode_checker),
- DocTestSuite('zope.i18n.locales.xmlfactory', checker=unicode_checker),
- ))
+ return unittest.TestSuite(
+ (
+ DocTestSuite('zope.i18n.locales', checker=unicode_checker),
+ DocTestSuite(
+ 'zope.i18n.locales.inheritance', checker=unicode_checker
+ ),
+ DocTestSuite(
+ 'zope.i18n.locales.xmlfactory', checker=unicode_checker
+ ),
+ )
+ )
+
if __name__ == '__main__':
unittest.main()
diff --git a/src/zope/i18n/locales/tests/test_fallbackcollator.py b/src/zope/i18n/locales/tests/test_fallbackcollator.py
index 7e10b50..4ecf34d 100644
--- a/src/zope/i18n/locales/tests/test_fallbackcollator.py
+++ b/src/zope/i18n/locales/tests/test_fallbackcollator.py
@@ -17,11 +17,16 @@ import doctest
from zope.i18n.testing import unicode_checker
+
def test_suite():
- return unittest.TestSuite((
- doctest.DocFileSuite('../fallbackcollator.txt', checker=unicode_checker),
- ))
+ return unittest.TestSuite(
+ (
+ doctest.DocFileSuite(
+ '../fallbackcollator.txt', checker=unicode_checker
+ ),
+ )
+ )
+
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
-
diff --git a/src/zope/i18n/locales/tests/test_locales.py b/src/zope/i18n/locales/tests/test_locales.py
index 2b100b8..58cecda 100644
--- a/src/zope/i18n/locales/tests/test_locales.py
+++ b/src/zope/i18n/locales/tests/test_locales.py
@@ -22,8 +22,10 @@ from zope.i18n.locales import locales
from zope.i18n.locales.provider import LocaleProvider, LoadLocaleError
import zope.i18n
+
datadir = os.path.join(os.path.dirname(zope.i18n.__file__), 'locales', 'data')
+
class AbstractTestILocaleProviderMixin(object):
"""Test the functionality of an implmentation of the ILocaleProvider
interface."""
@@ -60,14 +62,14 @@ class AbstractTestILocaleProviderMixin(object):
class TestLocaleProvider(AbstractTestILocaleProviderMixin, TestCase):
-
def _makeNewProvider(self):
return LocaleProvider(datadir)
def test_loadLocale(self):
self.locales.loadLocale(None, None, None)
- self.assertEqual(list(self.locales._locales.keys()),
- [(None, None, None)])
+ self.assertEqual(
+ list(self.locales._locales.keys()), [(None, None, None)]
+ )
self.locales.loadLocale('en', None, None)
self.assertIn(('en', None, None), self.locales._locales.keys())
@@ -94,27 +96,34 @@ class TestLocaleAndProvider(TestCase):
def test_getTimeFormatter(self):
formatter = self.locale.dates.getFormatter('time', 'medium')
self.assertEqual(formatter.getPattern(), 'h:mm:ss a')
- self.assertEqual(formatter.format(datetime.time(12, 30, 10)),
- '12:30:10 PM')
- self.assertEqual(formatter.parse('12:30:10 PM'),
- datetime.time(12, 30, 10))
+ self.assertEqual(
+ formatter.format(datetime.time(12, 30, 10)), '12:30:10 PM'
+ )
+ self.assertEqual(
+ formatter.parse('12:30:10 PM'), datetime.time(12, 30, 10)
+ )
def test_getDateFormatter(self):
formatter = self.locale.dates.getFormatter('date', 'medium')
self.assertEqual(formatter.getPattern(), 'MMM d, yyyy')
- self.assertEqual(formatter.format(datetime.date(2003, 1, 2)),
- 'Jan 2, 2003')
- self.assertEqual(formatter.parse('Jan 2, 2003'),
- datetime.date(2003, 1, 2))
+ self.assertEqual(
+ formatter.format(datetime.date(2003, 1, 2)), 'Jan 2, 2003'
+ )
+ self.assertEqual(
+ formatter.parse('Jan 2, 2003'), datetime.date(2003, 1, 2)
+ )
def test_getDateTimeFormatter(self):
formatter = self.locale.dates.getFormatter('dateTime', 'medium')
self.assertEqual(formatter.getPattern(), 'MMM d, yyyy h:mm:ss a')
self.assertEqual(
formatter.format(datetime.datetime(2003, 1, 2, 12, 30)),
- 'Jan 2, 2003 12:30:00 PM')
- self.assertEqual(formatter.parse('Jan 2, 2003 12:30:00 PM'),
- datetime.datetime(2003, 1, 2, 12, 30))
+ 'Jan 2, 2003 12:30:00 PM',
+ )
+ self.assertEqual(
+ formatter.parse('Jan 2, 2003 12:30:00 PM'),
+ datetime.datetime(2003, 1, 2, 12, 30),
+ )
def test_getNumberFormatter(self):
formatter = self.locale.numbers.getFormatter('decimal')
@@ -126,7 +135,6 @@ class TestLocaleAndProvider(TestCase):
class TestGlobalLocaleProvider(TestCase):
-
def testLoading(self):
locales.loadLocale(None, None, None)
self.assertIn((None, None, None), locales._locales)
@@ -143,6 +151,7 @@ class TestGlobalLocaleProvider(TestCase):
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."""
@@ -153,10 +162,14 @@ class TestRootLocale(TestCase):
def test_dateFormatter(self):
formatter = self.locale.dates.getFormatter('date')
self.assertEqual(
- formatter.format(datetime.date(2004, 10, 31), 'E'), '1')
+ formatter.format(datetime.date(2004, 10, 31), 'E'), '1'
+ )
self.assertEqual(
- formatter.format(datetime.date(2004, 10, 31), 'EE'), '01')
+ formatter.format(datetime.date(2004, 10, 31), 'EE'), '01'
+ )
self.assertEqual(
- formatter.format(datetime.date(2004, 10, 31), 'EEE'), '1')
+ formatter.format(datetime.date(2004, 10, 31), 'EEE'), '1'
+ )
self.assertEqual(
- formatter.format(datetime.date(2004, 10, 31), 'EEEE'), '1')
+ formatter.format(datetime.date(2004, 10, 31), 'EEEE'), '1'
+ )
diff --git a/src/zope/i18n/locales/tests/test_xmlfactory.py b/src/zope/i18n/locales/tests/test_xmlfactory.py
index 792c96d..b1c09bd 100644
--- a/src/zope/i18n/locales/tests/test_xmlfactory.py
+++ b/src/zope/i18n/locales/tests/test_xmlfactory.py
@@ -19,6 +19,7 @@ from unittest import TestCase, TestSuite
from zope.i18n.locales.xmlfactory import LocaleFactory
import zope.i18n
+
class LocaleXMLFileTestCase(TestCase):
"""This test verifies that every locale XML file can be loaded."""
@@ -34,13 +35,13 @@ class LocaleXMLFileTestCase(TestCase):
# necessary for the xml files to have all format definitions.
## Making sure all number format patterns parse
- #for category in (u'decimal', u'scientific', u'percent', u'currency'):
+ # 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 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():
@@ -48,11 +49,11 @@ class LocaleXMLFileTestCase(TestCase):
# parseDateTimePattern(format.pattern) is not None)
-
def test_suite():
suite = TestSuite()
- locale_dir = os.path.join(os.path.dirname(zope.i18n.__file__),
- 'locales', 'data')
+ 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