Test failures related to dates and i18n

8 views
Skip to first unread message

Remy Blank

unread,
Mar 28, 2013, 8:28:20 AM3/28/13
to trac...@googlegroups.com
I just ran our test suite on 1.0-stable, and I have a number of test
failures related to dates and i18n. This may be due to my slightly
special locale setup (en_CH is a custom locale), but AFAIU the tests
shouldn't depend on the my locale.

$ locale
LANG=en_US.utf8
LC_CTYPE=de_CH.utf8
LC_NUMERIC=en_CH.utf8
LC_TIME=en_CH.utf8
LC_COLLATE=en_CH.utf8
LC_MONETARY=en_CH.utf8
LC_MESSAGES=en_US.utf8
LC_PAPER=en_CH.utf8
LC_NAME=en_CH.utf8
LC_ADDRESS=en_CH.utf8
LC_TELEPHONE=en_CH.utf8
LC_MEASUREMENT=en_CH.utf8
LC_IDENTIFICATION=en_CH.utf8
LC_ALL=

Any ideas?

-- Remy


======================================================================
ERROR: test_i18n_parse_date_date (__main__.I18nDateFormatTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "trac/util/tests/datefmt.py", line 937, in test_i18n_parse_date_date
datefmt.parse_date('28 Aug 2010', tz, en_GB))
File "/home/joe/src/trac/1.0-stable/trac/util/datefmt.py", line 470,
in parse_date
date=text, hint=hint), _('Invalid Date'))
TracError: "28 Aug 2010" is an invalid date, or the date format is not
known. Try "MM/DD/YY" instead.

======================================================================
ERROR: test_i18n_parse_date_datetime (__main__.I18nDateFormatTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "trac/util/tests/datefmt.py", line 837, in
test_i18n_parse_date_datetime
en_US))
File "/home/joe/src/trac/1.0-stable/trac/util/datefmt.py", line 470,
in parse_date
date=text, hint=hint), _('Invalid Date'))
TracError: "Aug 28, 2010 1:45:56 PM" is an invalid date, or the date
format is not known. Try "MM/DD/YY" instead.

======================================================================
ERROR: test_i18n_parse_date_datetime_meridiem
(__main__.I18nDateFormatTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "trac/util/tests/datefmt.py", line 900, in
test_i18n_parse_date_datetime_meridiem
en_US))
File "/home/joe/src/trac/1.0-stable/trac/util/datefmt.py", line 470,
in parse_date
date=text, hint=hint), _('Invalid Date'))
TracError: "Feb 22, 2011 0:45:56 AM" is an invalid date, or the date
format is not known. Try "MM/DD/YY" instead.

======================================================================
FAIL: test_format_compatibility (__main__.I18nDateFormatTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "trac/util/tests/datefmt.py", line 981, in test_format_compatibility
datefmt.format_datetime(t, '%x %X', tz, en_US))
AssertionError: 'Aug 28, 2010 1:45:56 PM' != u'08/28/10 13:45:56'

======================================================================
FAIL: test_i18n_date_hint (__main__.I18nDateFormatTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "trac/util/tests/datefmt.py", line 788, in test_i18n_date_hint
in ('MMM d, yyyy', 'MMM d, y'))
AssertionError

======================================================================
FAIL: test_i18n_datetime_hint (__main__.I18nDateFormatTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "trac/util/tests/datefmt.py", line 767, in test_i18n_datetime_hint
in ('MMM d, yyyy h:mm:ss a', 'MMM d, y h:mm:ss a'))
AssertionError

======================================================================
FAIL: test_i18n_format_date (__main__.I18nDateFormatTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "trac/util/tests/datefmt.py", line 718, in test_i18n_format_date
datefmt.format_date(t, tzinfo=tz, locale=en_US))
AssertionError: 'Aug 7, 2010' != u'08/07/10'

======================================================================
FAIL: test_i18n_format_datetime (__main__.I18nDateFormatTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "trac/util/tests/datefmt.py", line 694, in test_i18n_format_datetime
locale=en_US))
AssertionError: 'Aug 28, 2010 1:45:56 PM' != u'08/28/10 13:45:56'

======================================================================
FAIL: test_i18n_format_time (__main__.I18nDateFormatTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "trac/util/tests/datefmt.py", line 746, in test_i18n_format_time
datefmt.format_time(t, tzinfo=tz, locale=en_US))
AssertionError: '1:45:56 PM' != u'13:45:56'

----------------------------------------------------------------------
Ran 94 tests in 0.044s

FAILED (failures=6, errors=3)

signature.asc

Jun Omae

unread,
Mar 29, 2013, 8:13:26 AM3/29/13
to trac...@googlegroups.com
Hi Rémy,

On Thu, Mar 28, 2013 at 9:28 PM, Remy Blank <remy....@pobox.com> wrote:
> I just ran our test suite on 1.0-stable, and I have a number of test
> failures related to dates and i18n. This may be due to my slightly
> special locale setup (en_CH is a custom locale), but AFAIU the tests
> shouldn't depend on the my locale.

Reproduced with babel-1.0dev. The issue doesn't depend on user locale.

Trac uses `babel.localedata.list` to retrieve known locales in Babel
in trac:r11691 [1]. But the `list` has been renamed to
`locale_identifiers` in babel:r599/trunk [2].

[1] http://trac.edgewall.org/changeset/11691
[2] http://babel.edgewall.org/changeset/599


diff --git a/trac/util/datefmt.py b/trac/util/datefmt.py
index 1620dfd..cb99cfe 100644
--- a/trac/util/datefmt.py
+++ b/trac/util/datefmt.py
@@ -36,7 +36,10 @@ try:
get_time_format, get_month_names,
get_period_names, get_day_names
)
- from babel.localedata import list as get_known_locales
+ try:
+ from babel.localedata import list as get_known_locales
+ except ImportError:
+ from babel.localedata import locale_identifiers as get_known_locales

except ImportError:
babel = None


--
Jun Omae <jun...@gmail.com> (大前 潤)
Reply all
Reply to author
Forward
0 new messages