Opened 17 months ago
Last modified 7 months ago
#13482 assigned defect
6 failures in unit-test with Babel 2.10.1
| Reported by: | Jun Omae | Owned by: | Jun Omae |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.6.1 |
| Component: | i18n | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Branch: | ||
| Release Notes: | |||
| API Changes: | |||
| Internal Changes: | |||
Description
Babel 2.10.1 has been released recently, which upgraded CLDR 41 from CLDR 37.
======================================================================
FAIL: test_i18n_datetime_hint (trac.util.tests.datefmt.I18nDateFormatTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jun66j5/src/tracdev/git/trac/util/tests/datefmt.py", line 1250, in test_i18n_datetime_hint
self.assertIn(datefmt.get_datetime_format_hint(fr),
AssertionError: 'd MMM y, HH:mm:ss' not found in ('d MMM yyyy HH:mm:ss', 'd MMM y HH:mm:ss', "d MMM y 'à' HH:mm:ss")
======================================================================
FAIL: test_i18n_format_datetime (trac.util.tests.datefmt.I18nDateFormatTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jun66j5/src/tracdev/git/trac/util/tests/datefmt.py", line 1175, in test_i18n_format_datetime
self.assertIn(datefmt.format_datetime(t, tzinfo=tz, locale=fr),
AssertionError: '28 août 2010, 13:45:56' not found in ('28 août 2010 13:45:56', '28 août 2010 à 13:45:56')
======================================================================
FAIL: test_i18n_format_time (trac.util.tests.datefmt.I18nDateFormatTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jun66j5/src/tracdev/git/trac/util/tests/datefmt.py", line 1233, in test_i18n_format_time
self.assertIn(datefmt.format_time(t, tzinfo=tz, locale=zh_CN),
AssertionError: '13:45:56' not found in ('下午01:45:56', '下午1:45:56')
======================================================================
FAIL: test_i18n_parse_date_datetime (trac.util.tests.datefmt.I18nDateFormatTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jun66j5/src/tracdev/git/trac/util/tests/datefmt.py", line 1367, in test_i18n_parse_date_datetime
self.assertEqual(expected,
AssertionError: datet[16 chars]0, 8, 28, 13, 45, 56, tzinfo=<FixedOffset "GMT +2:00" 2:00:00>) != datet[16 chars]0, 8, 28, 1, 45, 56, tzinfo=<FixedOffset "GMT +2:00" 2:00:00>)
======================================================================
FAIL: test_i18n_parse_date_datetime_meridiem (trac.util.tests.datefmt.I18nDateFormatTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jun66j5/src/tracdev/git/trac/util/tests/datefmt.py", line 1398, in test_i18n_parse_date_datetime_meridiem
self.assertEqual(expected_am,
AssertionError: datet[16 chars]1, 2, 22, 0, 45, 56, tzinfo=<FixedOffset "GMT +2:00" 2:00:00>) != datet[16 chars]1, 2, 22, 12, 45, 56, tzinfo=<FixedOffset "GMT +2:00" 2:00:00>)
======================================================================
FAIL: test_i18n_parse_date_roundtrip (trac.util.tests.datefmt.I18nDateFormatTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jun66j5/src/tracdev/git/trac/util/tests/datefmt.py", line 1454, in test_i18n_parse_date_roundtrip
self.assertEqual(tz_t, actual,
AssertionError: datet[16 chars]0, 8, 28, 13, 45, 56, tzinfo=<FixedOffset "GMT +2:00" 2:00:00>) != datet[16 chars]0, 8, 28, 1, 45, 56, tzinfo=<FixedOffset "GMT +2:00" 2:00:00>) : datetime.datetime(2010, 8, 28, 13, 45, 56, tzinfo=<FixedOffset "GMT +2:00" 2:00:00>) != datetime.datetime(2010, 8, 28, 1, 45, 56, tzinfo=<FixedOffset "GMT +2:00" 2:00:00>) ('2010年8月28日 B1:45:56' Locale('zh', territory='TW', script='Hant'))
----------------------------------------------------------------------
Ran 2762 tests in 41.802s
FAILED (failures=6, skipped=5)
Attachments (0)
Change History (8)
comment:1 by , 17 months ago
comment:2 by , 17 months ago
I've filed at https://github.com/python-babel/babel/issues/866.
B symbol in date pattern is not supported, however it is used in the pattern for zh_TW locale….
>>> fmt = dates.get_time_format('medium', 'zh_TW')
>>> vars(fmt)
{'pattern': 'Bh:mm:ss', 'format': 'B%(h)s:%(mm)s:%(ss)s'}
comment:3 by , 17 months ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
I posted babel PR#869 for supporting B symbol in time format.
Also, proposed changes in jomae.git@trunk:t13482 (diff), tested with the PR.
comment:4 by , 17 months ago
I noticed the proposed changes are incomplete. parse_date() handles only am/pm periods, however other periods are used in formatting time with zh_TW locale.
>>> for h in range(24): ... d = datetime(2029, 4, 29, h, tzinfo=datefmt.utc) ... print(d.isoformat(), '→', dates.format_datetime(d, tzinfo=d.tzinfo, locale=zh_TW)) ... 2029-04-29T00:00:00+00:00 → 2029年4月29日 午夜12:00:00 2029-04-29T01:00:00+00:00 → 2029年4月29日 凌晨1:00:00 2029-04-29T02:00:00+00:00 → 2029年4月29日 凌晨2:00:00 2029-04-29T03:00:00+00:00 → 2029年4月29日 凌晨3:00:00 2029-04-29T04:00:00+00:00 → 2029年4月29日 凌晨4:00:00 2029-04-29T05:00:00+00:00 → 2029年4月29日 清晨5:00:00 2029-04-29T06:00:00+00:00 → 2029年4月29日 清晨6:00:00 2029-04-29T07:00:00+00:00 → 2029年4月29日 清晨7:00:00 2029-04-29T08:00:00+00:00 → 2029年4月29日 上午8:00:00 2029-04-29T09:00:00+00:00 → 2029年4月29日 上午9:00:00 2029-04-29T10:00:00+00:00 → 2029年4月29日 上午10:00:00 2029-04-29T11:00:00+00:00 → 2029年4月29日 上午11:00:00 2029-04-29T12:00:00+00:00 → 2029年4月29日 中午12:00:00 2029-04-29T13:00:00+00:00 → 2029年4月29日 下午1:00:00 2029-04-29T14:00:00+00:00 → 2029年4月29日 下午2:00:00 2029-04-29T15:00:00+00:00 → 2029年4月29日 下午3:00:00 2029-04-29T16:00:00+00:00 → 2029年4月29日 下午4:00:00 2029-04-29T17:00:00+00:00 → 2029年4月29日 下午5:00:00 2029-04-29T18:00:00+00:00 → 2029年4月29日 下午6:00:00 2029-04-29T19:00:00+00:00 → 2029年4月29日 晚上7:00:00 2029-04-29T20:00:00+00:00 → 2029年4月29日 晚上8:00:00 2029-04-29T21:00:00+00:00 → 2029年4月29日 晚上9:00:00 2029-04-29T22:00:00+00:00 → 2029年4月29日 晚上10:00:00 2029-04-29T23:00:00+00:00 → 2029年4月29日 晚上11:00:00 >>> datefmt.parse_date('2029年4月29日 晚上8:00:00', tzinfo=datefmt.utc, locale=zh_TW).isoformat() '2029-04-29T08:00:00+00:00' # => should be '2029-04-29T20:00:00+00:00'
comment:5 by , 17 months ago
Another point, datetime picker must parse formatted datetime string by format_datetime().
comment:6 by , 15 months ago
Babel 2.10.3 is released recently. The B symbol in time format for zh_TW locale is supported now. I'll try to fix parse_date in Trac core….
>>> import babel >>> babel.__version__ '2.10.3' >>> from datetime import datetime >>> from babel import dates >>> dates.format_time(datetime(2022, 6, 24, 12, 34, 56), locale='zh_TW') '中午12:34:56'
comment:8 by , 7 months ago
| Milestone: | 1.5.5 → 1.6.1 |
|---|



Hmm,
babel.dates.format_datetime()in Babel 2.10.1 is broken with zh_TW locale. 1:00 and 13:00 are formatted to incorrectly same text with zh_TW locale.