There are some test failures with non-English locales. I use Babel 1.3.
The following output is with pl_PL.UTF-8 locale:
$ py.test-2.7
/usr/lib64/python2.7/site-packages/_pytest/assertion/oldinterpret.py:3: DeprecationWarning: The compiler package is deprecated and removed in Python 3.x.
from compiler import parse, ast, pycodegen
============================= test session starts ==============================
platform linux2 -- Python 2.7.6 -- pytest-2.3.5
collected 344 items
babel/__init__.py .
babel/_compat.py .
babel/core.py .
babel/dates.py F
babel/localedata.py .
babel/numbers.py .
babel/plural.py .
babel/support.py .
babel/util.py .
babel/localtime/__init__.py .
babel/localtime/_unix.py .
babel/localtime/_win32.py .
babel/messages/__init__.py .
babel/messages/catalog.py .
babel/messages/checkers.py .
babel/messages/extract.py .
babel/messages/frontend.py .
babel/messages/jslexer.py .
babel/messages/mofile.py .
babel/messages/plurals.py .
babel/messages/pofile.py .
tests/test_core.py ..............................................
tests/test_dates.py ............................................................
tests/test_localedata.py ......
tests/test_numbers.py ..........F................
tests/test_plural.py .......
tests/test_support.py ..........................
tests/test_util.py ..
tests/messages/test_catalog.py ....................................
tests/messages/test_checkers.py ......
tests/messages/test_extract.py ....................................
tests/messages/test_frontend.py ................................
tests/messages/test_jslexer.py .
tests/messages/test_mofile.py ...
tests/messages/test_plurals.py .
tests/messages/test_pofile.py ..................................
=================================== FAILURES ===================================
__________________________________ [doctest] ___________________________________
727
728 >>> format_timedelta(timedelta(hours=23), threshold=0.9, locale='en_US')
729 u'1 day'
730 >>> format_timedelta(timedelta(hours=23), threshold=1.1, locale='en_US')
731 u'23 hours'
732
733 In addition directional information can be provided that informs
734 the user if the date is in the past or in the future:
735
736 >>> format_timedelta(timedelta(hours=1), add_direction=True)
Expected:
u'In 1 hour'
Got:
u'Za 1 godzin\u0119'
/tmp/Babel-1.3/babel/dates.py:736: DocTestFailure
____________________________ test_get_currency_name ____________________________
def test_get_currency_name():
> assert numbers.get_currency_name('USD', 'en_US') == u'US dollars'
tests/test_numbers.py:176:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
currency = 'USD', count = 'en_US', locale = 'pl_PL'
def get_currency_name(currency, count=None, locale=LC_NUMERIC):
"""Return the name used by the locale for the specified currency.
>>> get_currency_name('USD', locale='en_US')
u'US Dollar'
.. versionadded:: 0.9.4
:param currency: the currency code
:param count: the optional count. If provided the currency name
will be pluralized to that number if possible.
:param locale: the `Locale` object or locale identifier
"""
loc = Locale.parse(locale)
if count is not None:
> plural_form = loc.plural_form(count)
babel/numbers.py:47:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <PluralRule 'one: n is 1, few: n mod 10 in 2..4 and n mod 100 not in 12..14, many: n is not 1 and n mod 10 in 0..1 or n mod 10 in 5..9 or n mod 100 in 12..14'>
n = 'en_US'
def __call__(self, n):
if not hasattr(self, '_func'):
self._func = to_python(self)
> return self._func(n)
babel/plural.py:105:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
n = 'en_US'
> ???
<rule>:2:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
a = 'en_US', b = 10
def cldr_modulo(a, b):
"""Javaish modulo. This modulo operator returns the value with the sign
of the dividend rather than the divisor like Python does:
>>> cldr_modulo(-3, 5)
-3
>>> cldr_modulo(-3, -5)
-3
>>> cldr_modulo(3, 5)
3
"""
reverse = 0
if a < 0:
a *= -1
reverse = 1
if b < 0:
b *= -1
> rv = a % b
E TypeError: not all arguments converted during string formatting
babel/plural.py:247: TypeError
===================== 2 failed, 342 passed in 4.76 seconds =====================
�$ py.test-3.3
============================= test session starts ==============================
platform linux -- Python 3.3.3 -- pytest-2.3.5
collected 323 items
tests/test_core.py ..............................................
tests/test_dates.py ............................................................
tests/test_localedata.py ......
tests/test_numbers.py ..........F................
tests/test_plural.py .......
tests/test_support.py ..........................
tests/test_util.py ..
tests/messages/test_catalog.py ....................................
tests/messages/test_checkers.py ......
tests/messages/test_extract.py ....................................
tests/messages/test_frontend.py ...................F............
tests/messages/test_jslexer.py .
tests/messages/test_mofile.py ...
tests/messages/test_plurals.py .
tests/messages/test_pofile.py ..................................
=================================== FAILURES ===================================
____________________________ test_get_currency_name ____________________________
def test_get_currency_name():
> assert numbers.get_currency_name('USD', 'en_US') == u'US dollars'
tests/test_numbers.py:176:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
currency = 'USD', count = 'en_US', locale = 'pl_PL'
def get_currency_name(currency, count=None, locale=LC_NUMERIC):
"""Return the name used by the locale for the specified currency.
>>> get_currency_name('USD', locale='en_US')
u'US Dollar'
.. versionadded:: 0.9.4
:param currency: the currency code
:param count: the optional count. If provided the currency name
will be pluralized to that number if possible.
:param locale: the `Locale` object or locale identifier
"""
loc = Locale.parse(locale)
if count is not None:
> plural_form = loc.plural_form(count)
babel/numbers.py:47:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <PluralRule 'one: n is 1, few: n mod 10 in 2..4 and n mod 100 not in 12..14, many: n is not 1 and n mod 10 in 0..1 or n mod 10 in 5..9 or n mod 100 in 12..14'>
n = 'en_US'
def __call__(self, n):
if not hasattr(self, '_func'):
self._func = to_python(self)
> return self._func(n)
babel/plural.py:105:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
n = 'en_US'
> ???
<rule>:2:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
a = 'en_US', b = 10
def cldr_modulo(a, b):
"""Javaish modulo. This modulo operator returns the value with the sign
of the dividend rather than the divisor like Python does:
>>> cldr_modulo(-3, 5)
-3
>>> cldr_modulo(-3, -5)
-3
>>> cldr_modulo(3, 5)
3
"""
reverse = 0
> if a < 0:
E TypeError: unorderable types: str() < int()
babel/plural.py:242: TypeError
CommandLineInterfaceTestCase.test_compile_catalog_with_more_than_2_plural_forms
self = <tests.messages.test_frontend.CommandLineInterfaceTestCase testMethod=test_compile_catalog_with_more_than_2_plural_forms>
def test_compile_catalog_with_more_than_2_plural_forms(self):
po_file = self._po_file('ru_RU')
mo_file = po_file.replace('.po', '.mo')
try:
self.cli.run(sys.argv + ['compile',
'--locale', 'ru_RU', '--use-fuzzy',
'-d', self._i18n_dir()])
assert os.path.isfile(mo_file)
self.assertEqual("""\
compiling catalog %r to %r
> """ % (po_file, mo_file), sys.stderr.getvalue())
E AssertionError: "compiling catalog '/tmp/Babel-1.3/tests/messages/data/project/i18n/ru_RU/LC_MES [truncated]... != "compiling catalog '/tmp/Babel-1.3/tests/messages/data/project/i18n/ru_RU/LC_MES [truncated]...
E compiling catalog '/tmp/Babel-1.3/tests/messages/data/project/i18n/ru_RU/LC_MESSAGES/messages.po' to '/tmp/Babel-1.3/tests/messages/data/project/i18n/ru_RU/LC_MESSAGES/messages.mo'
E + /tmp/Babel-1.3/babel/messages/frontend.py:794: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
E + write_mo(outfile, catalog, use_fuzzy=options.use_fuzzy)
tests/messages/test_frontend.py:1051: AssertionError
===================== 2 failed, 321 passed in 3.48 seconds =====================