getnikola / nikola

A static website and blog generator
https://getnikola.com/
MIT License
2.6k stars 444 forks source link

8.2.4: several locale related tests fail #3684

Closed dvzrv closed 1 year ago

dvzrv commented 1 year ago

Environment

Python Version: 3.10.10

Nikola Version: 8.2.4

Operating System: Arch Linux

Description:

When building 8.2.4 for Arch Linux against Python 3.10 I am seeing the following locale/date related issues:

=================================== FAILURES ===================================
____________________________ test_format_date_long _____________________________

base_config = None

    def test_format_date_long(base_config):
>       assert LocaleBorg().formatted_date("long", TESLA_BIRTHDAY_DT) == DT_EN_US
E       AssertionError: assert 'July 10, 1856 at 12:34:56 PM UTC' == 'July 10, 1856, 12:34:56\u202fPM UTC'
E         - July 10, 1856, 12:34:56 PM UTC
E         ?              ^         ^
E         + July 10, 1856 at 12:34:56 PM UTC
E         ?              ^^^         ^

tests/test_locale.py:77: AssertionError
__________________________ test_format_date_timezone ___________________________

base_config = None

    def test_format_date_timezone(base_config):
        tesla_150_birthday_dtz = datetime.datetime(
            2006, 7, 10, 12, 34, 56, tzinfo=dateutil.tz.gettz("America/New_York")
        )
        formatted_date = LocaleBorg().formatted_date("long", tesla_150_birthday_dtz)
>       assert formatted_date == "July 10, 2006, 12:34:56\u202fPM -0400"
E       AssertionError: assert 'July 10, 2006 at 12:34:56 PM -0400' == 'July 10, 2006, 12:34:56\u202fPM -0400'
E         - July 10, 2006, 12:34:56 PM -0400
E         ?              ^         ^
E         + July 10, 2006 at 12:34:56 PM -0400
E         ?              ^^^         ^

tests/test_locale.py:90: AssertionError
_____________________ test_format_date_locale_variants[US] _____________________

english_variant = 'en_US', expected_date = 'July 10, 1856, 12:34:56\u202fPM UTC'

    @pytest.mark.parametrize(
        "english_variant, expected_date",
        [
            pytest.param("en_US", DT_EN_US, id="US"),
            pytest.param("en_GB", "10 July 1856, 12:34:56 UTC", id="GB"),
        ],
    )
    def test_format_date_locale_variants(english_variant, expected_date):
        LocaleBorg.initialize({"en": english_variant}, "en")
>       assert LocaleBorg().formatted_date("long", TESLA_BIRTHDAY_DT, "en") == expected_date
E       AssertionError: assert 'July 10, 1856 at 12:34:56 PM UTC' == 'July 10, 1856, 12:34:56\u202fPM UTC'
E         - July 10, 1856, 12:34:56 PM UTC
E         ?              ^         ^
E         + July 10, 1856 at 12:34:56 PM UTC
E         ?              ^^^         ^

tests/test_locale.py:108: AssertionError
_____________________ test_format_date_locale_variants[GB] _____________________

english_variant = 'en_GB', expected_date = '10 July 1856, 12:34:56 UTC'

    @pytest.mark.parametrize(
        "english_variant, expected_date",
        [
            pytest.param("en_US", DT_EN_US, id="US"),
            pytest.param("en_GB", "10 July 1856, 12:34:56 UTC", id="GB"),
        ],
    )
    def test_format_date_locale_variants(english_variant, expected_date):
        LocaleBorg.initialize({"en": english_variant}, "en")
>       assert LocaleBorg().formatted_date("long", TESLA_BIRTHDAY_DT, "en") == expected_date
E       AssertionError: assert '10 July 1856 at 12:34:56 UTC' == '10 July 1856, 12:34:56 UTC'
E         - 10 July 1856, 12:34:56 UTC
E         ?             ^
E         + 10 July 1856 at 12:34:56 UTC
E         ?             ^^^

tests/test_locale.py:108: AssertionError
=============================== warnings summary ===============================
../../../../usr/lib/python3.10/site-packages/pkg_resources/__init__.py:121
  /usr/lib/python3.10/site-packages/pkg_resources/__init__.py:121: DeprecationWarning: pkg_resources is deprecated as an API
    warnings.warn("pkg_resources is deprecated as an API", DeprecationWarning)

../../../../usr/lib/python3.10/site-packages/pkg_resources/__init__.py:2870
../../../../usr/lib/python3.10/site-packages/pkg_resources/__init__.py:2870
  /usr/lib/python3.10/site-packages/pkg_resources/__init__.py:2870: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('ruamel')`.
  Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
    declare_namespace(pkg)

../../../../usr/lib/python3.10/site-packages/yapsy/PluginManager.py:134
  /usr/lib/python3.10/site-packages/yapsy/PluginManager.py:134: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
    import imp

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED tests/test_locale.py::test_format_date_long - AssertionError: assert '...
FAILED tests/test_locale.py::test_format_date_timezone - AssertionError: asse...
FAILED tests/test_locale.py::test_format_date_locale_variants[US] - Assertion...
FAILED tests/test_locale.py::test_format_date_locale_variants[GB] - Assertion...
= 4 failed, 471 passed, 16 skipped, 4 deselected, 5 xfailed, 4 warnings in 37.15s =

nikola-8.2.4-1-x86_64-build.log nikola-8.2.4-1-x86_64-check.log

FWIW: The same happens when building against our Python 3.11 target (currently in testing).

Kwpolska commented 1 year ago

It looks like you’re using an old version of Babel: Arch is at 2.11.0, but upstream is at 2.12.1 (since 28 February 2023). That new Babel version brought a new CLDR version with the English date format changed. Our test suite expects the latest versions of dependencies.

Foxboron commented 1 year ago

2.11.0 is shipping with cldr 41 which you are linking towards. But you probably mean cldr 42 which is what 2.12.1 is using.

https://www.unicode.org/cldr/charts/42/delta/en.html#Formats%20-%20Standard%20-%20Date%20&%20Time%20Combination%20Formats