]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Adjust tests for CLDR 42 951/head
authorAarni Koskela <akx@iki.fi>
Fri, 20 Jan 2023 14:55:38 +0000 (16:55 +0200)
committerAarni Koskela <akx@iki.fi>
Fri, 20 Jan 2023 15:09:15 +0000 (17:09 +0200)
The space changes around English seem to be on purpose, see:

* https://unicode-org.atlassian.net/browse/CLDR-14032
* https://github.com/unicode-org/cldr/commit/a83026ab8c8fa6ed88f1047c4d0c6089f88b7e5d

babel/core.py
babel/dates.py
babel/numbers.py
babel/support.py
tests/test_core.py
tests/test_date_intervals.py
tests/test_dates.py
tests/test_numbers.py
tests/test_support.py

index ce564d75098740b126bf5942c08baf9fdefeca23..7d3191002fd91bf293467a61fe1ca000fa7184c5 100644 (file)
@@ -855,7 +855,7 @@ class Locale:
                   Babel versions.
 
         >>> Locale('en', 'US').time_formats['short']
-        <DateTimePattern u'h:mm a'>
+        <DateTimePattern u'h:mm\u202fa'>
         >>> Locale('fr', 'FR').time_formats['long']
         <DateTimePattern u'HH:mm:ss z'>
         """
@@ -869,7 +869,7 @@ class Locale:
                   Babel versions.
 
         >>> Locale('en').datetime_formats['full']
-        u"{1} 'at' {0}"
+        u'{1}, {0}'
         >>> Locale('th').datetime_formats['medium']
         u'{1} {0}'
         """
index e626df5c2df43ee23dffd98ebf1915939e713f2f..ce79318d0ca4a3398efae98964d842e9ad6dd754 100644 (file)
@@ -497,7 +497,7 @@ def get_time_format(format: _PredefinedTimeFormat = 'medium', locale: Locale | s
     format.
 
     >>> get_time_format(locale='en_US')
-    <DateTimePattern u'h:mm:ss a'>
+    <DateTimePattern u'h:mm:ss\u202fa'>
     >>> get_time_format('full', locale='de_DE')
     <DateTimePattern u'HH:mm:ss zzzz'>
 
@@ -580,14 +580,14 @@ def get_timezone_location(
 
     >>> tz = get_timezone('America/St_Johns')
     >>> print(get_timezone_location(tz, locale='de_DE'))
-    Kanada (St. John’s) Zeit
+    Kanada (St. John’s) (Ortszeit)
     >>> print(get_timezone_location(tz, locale='en'))
     Canada (St. John’s) Time
     >>> print(get_timezone_location(tz, locale='en', return_city=True))
     St. John’s
     >>> tz = get_timezone('America/Mexico_City')
     >>> get_timezone_location(tz, locale='de_DE')
-    u'Mexiko (Mexiko-Stadt) Zeit'
+    u'Mexiko (Mexiko-Stadt) (Ortszeit)'
 
     If the timezone is associated with a country that uses only a single
     timezone, just the localized country name is returned:
@@ -823,13 +823,13 @@ def format_datetime(
     >>> from datetime import datetime
     >>> dt = datetime(2007, 4, 1, 15, 30)
     >>> format_datetime(dt, locale='en_US')
-    u'Apr 1, 2007, 3:30:00 PM'
+    u'Apr 1, 2007, 3:30:00\u202fPM'
 
     For any pattern requiring the display of the timezone:
 
     >>> format_datetime(dt, 'full', tzinfo=get_timezone('Europe/Paris'),
     ...                 locale='fr_FR')
-    'dimanche 1 avril 2007 à 17:30:00 heure d’été d’Europe centrale'
+    'dimanche 1 avril 2007, 17:30:00 heure d’été d’Europe centrale'
     >>> format_datetime(dt, "yyyy.MM.dd G 'at' HH:mm:ss zzz",
     ...                 tzinfo=get_timezone('US/Eastern'), locale='en')
     u'2007.04.01 AD at 11:30:00 EDT'
@@ -864,7 +864,7 @@ def format_time(
     >>> from datetime import datetime, time
     >>> t = time(15, 30)
     >>> format_time(t, locale='en_US')
-    u'3:30:00 PM'
+    u'3:30:00\u202fPM'
     >>> format_time(t, format='short', locale='de_DE')
     u'15:30'
 
@@ -905,7 +905,7 @@ def format_time(
     u'15:30:00 heure normale d\u2019Europe centrale'
     >>> format_time(t, format='full', tzinfo=get_timezone('US/Eastern'),
     ...             locale='en_US')
-    u'3:30:00 PM Eastern Standard Time'
+    u'3:30:00\u202fPM Eastern Standard Time'
 
     :param time: the ``time`` or ``datetime`` object; if `None`, the current
                  time in UTC is used
@@ -1137,7 +1137,7 @@ def format_interval(
     '12:12\u201316:16'
 
     >>> format_interval(time(5, 12), time(16, 16), "hm", locale="en_US")
-    '5:12 AM \u2013 4:16 PM'
+    '5:12\u202fAM\u2009–\u20094:16\u202fPM'
 
     >>> format_interval(time(16, 18), time(16, 24), "Hm", locale="it")
     '16:18\u201316:24'
@@ -1156,7 +1156,7 @@ def format_interval(
     '16:18:00\uff5e16:24:00'
 
     >>> format_interval(date(2016, 1, 15), date(2016, 1, 17), "xxx", locale="de")
-    '15.01.2016 \u2013 17.01.2016'
+    '15.01.2016\u2009–\u200917.01.2016'
 
     :param start: First instant (datetime/date/time)
     :param end: Second instant (datetime/date/time)
index 399b70b5c50285b747292acda090739cf749bc54..d107046c1d26e7f1761cbf8a8f50988720134316 100644 (file)
@@ -558,9 +558,9 @@ def format_currency(
     """Return formatted currency value.
 
     >>> format_currency(1099.98, 'USD', locale='en_US')
-    u'$1,099.98'
+    '$1,099.98'
     >>> format_currency(1099.98, 'USD', locale='es_CO')
-    u'US$\\xa01.099,98'
+    u'US$1.099,98'
     >>> format_currency(1099.98, 'EUR', locale='de_DE')
     u'1.099,98\\xa0\\u20ac'
 
index 242b492bf8a44cbec573920e8e808d14963f0a49..aa7d8272635cb6571cb89a5d45285b7232092718 100644 (file)
@@ -83,7 +83,7 @@ class Format:
         >>> from babel.dates import get_timezone
         >>> fmt = Format('en_US', tzinfo=get_timezone('US/Eastern'))
         >>> fmt.datetime(datetime(2007, 4, 1, 15, 30))
-        u'Apr 1, 2007, 11:30:00 AM'
+        u'Apr 1, 2007, 11:30:00\u202fAM'
         """
         return format_datetime(datetime, format, tzinfo=self.tzinfo, locale=self.locale)
 
@@ -98,7 +98,7 @@ class Format:
         >>> from babel.dates import get_timezone
         >>> fmt = Format('en_US', tzinfo=get_timezone('US/Eastern'))
         >>> fmt.time(datetime(2007, 4, 1, 15, 30))
-        u'11:30:00 AM'
+        u'11:30:00\u202fAM'
         """
         return format_time(time, format, tzinfo=self.tzinfo, locale=self.locale)
 
index d315018b7f76fd7d17e7f6c7928b2faab7c291af..2a7e605c2784f8901551f61b9a6aecdf77f8862e 100644 (file)
@@ -228,11 +228,11 @@ class TestLocaleClass:
         assert Locale('fr', 'FR').date_formats['long'].pattern == 'd MMMM y'
 
     def test_time_formats_property(self):
-        assert Locale('en', 'US').time_formats['short'].pattern == 'h:mm a'
+        assert Locale('en', 'US').time_formats['short'].pattern == 'h:mm\u202fa'
         assert Locale('fr', 'FR').time_formats['long'].pattern == 'HH:mm:ss z'
 
     def test_datetime_formats_property(self):
-        assert Locale('en').datetime_formats['full'] == "{1} 'at' {0}"
+        assert Locale('en').datetime_formats['full'] == "{1}, {0}"
         assert Locale('th').datetime_formats['medium'] == '{1} {0}'
 
     def test_datetime_skeleton_property(self):
index 556585488dacabcdb259bdb6c176c206289b046d..55992b59511a428a8e6b6684386dc400d86e1a19 100644 (file)
@@ -13,7 +13,7 @@ def test_format_interval_same_instant_1():
 
 
 def test_format_interval_same_instant_2():
-    assert dates.format_interval(TEST_DT, TEST_DT, "xxx", fuzzy=False, locale="fi") == "8.1.2016 klo 11.46.15"
+    assert dates.format_interval(TEST_DT, TEST_DT, "xxx", fuzzy=False, locale="fi") == "8.1.2016 11.46.15"
 
 
 def test_format_interval_same_instant_3():
@@ -40,7 +40,7 @@ def test_format_interval_in_tz(timezone_getter):
 def test_format_interval_12_hour():
     t2 = TEST_DT
     t1 = t2 - datetime.timedelta(hours=1)
-    assert dates.format_interval(t1, t2, "hm", locale="en") == "10:46 \u2013 11:46 AM"
+    assert dates.format_interval(t1, t2, "hm", locale="en") == "10:46\u2009\u2013\u200911:46\u202fAM"
 
 
 def test_format_interval_invalid_skeleton():
index 0c8bd178f74aecf2c9ff65ca6d017af3e989c607..7ec4dc7cdd3922ba16a31f2619906cf25f1f1039 100644 (file)
@@ -439,7 +439,7 @@ def test_get_datetime_format():
 
 
 def test_get_time_format():
-    assert dates.get_time_format(locale='en_US').pattern == 'h:mm:ss a'
+    assert dates.get_time_format(locale='en_US').pattern == 'h:mm:ss\u202fa'
     assert (dates.get_time_format('full', locale='de_DE').pattern ==
             'HH:mm:ss zzzz')
 
@@ -460,7 +460,7 @@ def test_get_timezone_gmt(timezone_getter):
 def test_get_timezone_location(timezone_getter):
     tz = timezone_getter('America/St_Johns')
     assert (dates.get_timezone_location(tz, locale='de_DE') ==
-            "Kanada (St. John\u2019s) Zeit")
+            "Kanada (St. John\u2019s) (Ortszeit)")
     assert (dates.get_timezone_location(tz, locale='en') ==
             'Canada (St. John’s) Time')
     assert (dates.get_timezone_location(tz, locale='en', return_city=True) ==
@@ -468,11 +468,11 @@ def test_get_timezone_location(timezone_getter):
 
     tz = timezone_getter('America/Mexico_City')
     assert (dates.get_timezone_location(tz, locale='de_DE') ==
-            'Mexiko (Mexiko-Stadt) Zeit')
+            'Mexiko (Mexiko-Stadt) (Ortszeit)')
 
     tz = timezone_getter('Europe/Berlin')
     assert (dates.get_timezone_location(tz, locale='de_DE') ==
-            'Deutschland (Berlin) Zeit')
+            'Deutschland (Berlin) (Ortszeit)')
 
 
 @pytest.mark.parametrize(
@@ -564,7 +564,7 @@ def test_format_date():
 def test_format_datetime(timezone_getter):
     dt = datetime(2007, 4, 1, 15, 30)
     assert (dates.format_datetime(dt, locale='en_US') ==
-            'Apr 1, 2007, 3:30:00 PM')
+            'Apr 1, 2007, 3:30:00\u202fPM')
 
     full = dates.format_datetime(
         dt, 'full',
@@ -572,8 +572,8 @@ def test_format_datetime(timezone_getter):
         locale='fr_FR'
     )
     assert full == (
-        'dimanche 1 avril 2007 à 17:30:00 heure '
-        'd\u2019\xe9t\xe9 d\u2019Europe centrale'
+        'dimanche 1 avril 2007, 17:30:00 heure '
+        'd’été d’Europe centrale'
     )
     custom = dates.format_datetime(
         dt, "yyyy.MM.dd G 'at' HH:mm:ss zzz",
@@ -585,7 +585,7 @@ def test_format_datetime(timezone_getter):
 
 def test_format_time(timezone_getter):
     t = time(15, 30)
-    assert dates.format_time(t, locale='en_US') == '3:30:00 PM'
+    assert dates.format_time(t, locale='en_US') == '3:30:00\u202fPM'
     assert dates.format_time(t, format='short', locale='de_DE') == '15:30'
 
     assert (dates.format_time(t, "hh 'o''clock' a", locale='en') ==
@@ -606,7 +606,7 @@ def test_format_time(timezone_getter):
     assert paris == '15:30:00 heure normale d’Europe centrale'
 
     us_east = dates.format_time(t, format='full', tzinfo=eastern, locale='en_US')
-    assert us_east == '3:30:00 PM Eastern Standard Time'
+    assert us_east == '3:30:00\u202fPM Eastern Standard Time'
 
 
 def test_format_skeleton(timezone_getter):
@@ -720,7 +720,7 @@ def test_no_inherit_metazone_formatting(timezone_getter):
     # See: https://github.com/python-babel/babel/issues/428
     tz = timezone_getter('America/Los_Angeles')
     t = _localize(tz, datetime(2016, 1, 6, 7))
-    assert dates.format_time(t, format='long', locale='en_US') == "7:00:00 AM PST"
+    assert dates.format_time(t, format='long', locale='en_US') == "7:00:00\u202fAM PST"
     assert dates.format_time(t, format='long', locale='en_GB') == "07:00:00 Pacific Standard Time"
     assert dates.get_timezone_name(t, width='short', locale='en_US') == "PST"
     assert dates.get_timezone_name(t, width='short', locale='en_GB') == "Pacific Standard Time"
index 88df37619cc3441d8596ae9f6771b0fda300e8cc..c8a04d69626bbc3a8a4a64fa4059dcbec53d6c68 100644 (file)
@@ -388,7 +388,7 @@ def test_format_currency():
     assert (numbers.format_currency(0, 'USD', locale='en_US')
             == '$0.00')
     assert (numbers.format_currency(1099.98, 'USD', locale='es_CO')
-            == 'US$\xa01.099,98')
+            == 'US$1.099,98')
     assert (numbers.format_currency(1099.98, 'EUR', locale='de_DE')
             == '1.099,98\xa0\u20ac')
     assert (numbers.format_currency(1099.98, 'EUR', '\xa4\xa4 #,##0.00',
@@ -400,11 +400,11 @@ def test_format_currency():
                                     locale='en_US')
             == '$1,099.98')
     assert (numbers.format_currency(1, 'USD', locale='es_AR')
-            == 'US$\xa01,00')          # one
+            == 'US$1,00')          # one
     assert (numbers.format_currency(1000000, 'USD', locale='es_AR')
-            == 'US$\xa01.000.000,00')  # many
+            == 'US$1.000.000,00')  # many
     assert (numbers.format_currency(0, 'USD', locale='es_AR')
-            == 'US$\xa00,00')          # other
+            == 'US$0,00')          # other
 
 
 def test_format_currency_format_type():
@@ -449,8 +449,8 @@ def test_format_compact_currency():
     assert numbers.format_compact_currency(1234, 'JPY', locale='ja_JP', format_type="short") == '¥1234'
     assert numbers.format_compact_currency(123456, 'JPY', locale='ja_JP', format_type="short") == '¥12万'
     assert numbers.format_compact_currency(123456, 'JPY', locale='ja_JP', format_type="short", fraction_digits=2) == '¥12.35万'
-    assert numbers.format_compact_currency(123, 'EUR', locale='yav', format_type="short") == '123\xa0€'
-    assert numbers.format_compact_currency(12345, 'EUR', locale='yav', format_type="short") == '12K\xa0€'
+    assert numbers.format_compact_currency(123, 'EUR', locale='yav', format_type="short") == '€\xa0123'
+    assert numbers.format_compact_currency(12345, 'EUR', locale='yav', format_type="short") == '€\xa012K'
     assert numbers.format_compact_currency(123456789, 'EUR', locale='de_DE', fraction_digits=1) == '123,5\xa0Mio.\xa0€'
 
 
@@ -484,7 +484,11 @@ def test_format_compact_currency_invalid_format_type():
 def test_format_currency_precision(input_value, expected_value):
     # Test precision conservation.
     assert numbers.format_currency(
-        decimal.Decimal(input_value), 'USD', locale='en_US', decimal_quantization=False) == expected_value
+        decimal.Decimal(input_value),
+        currency='USD',
+        locale='en_US',
+        decimal_quantization=False,
+    ) == expected_value
 
 
 def test_format_currency_quantization():
index 0b7cba0674729b4ebcc0b77134acc018f653648a..a47113775a4f2ab5f05c09946931e24d59a24f22 100644 (file)
@@ -304,12 +304,12 @@ def test_format_date():
 def test_format_datetime(timezone_getter):
     fmt = support.Format('en_US', tzinfo=timezone_getter('US/Eastern'))
     when = datetime(2007, 4, 1, 15, 30)
-    assert fmt.datetime(when) == 'Apr 1, 2007, 11:30:00 AM'
+    assert fmt.datetime(when) == 'Apr 1, 2007, 11:30:00\u202fAM'
 
 
 def test_format_time(timezone_getter):
     fmt = support.Format('en_US', tzinfo=timezone_getter('US/Eastern'))
-    assert fmt.time(datetime(2007, 4, 1, 15, 30)) == '11:30:00 AM'
+    assert fmt.time(datetime(2007, 4, 1, 15, 30)) == '11:30:00\u202fAM'
 
 
 def test_format_timedelta():