getnikola / nikola

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

Babel 12.2.x test failures due to no-breaking spaces and slightly different output #3667

Closed hroncok closed 1 year ago

hroncok commented 1 year ago

Environment

Python Version: 3.11.2

Nikola Version: 8.2.3

Operating System: Fedora Linux 39

Description:

Hello, in Fedora we are updating our babel to 12.2.0 and I noticed some test failures of nikola. Unfortunately, I won't be able to provide a full producer as I run the tests in the Fedora package and I do not maintain that package. This is just a friendly heads-up for you, I don't expect you to do anything.

The test failures are

+ pytest
============================= test session starts ==============================
platform linux -- Python 3.11.2, pytest-7.2.1, pluggy-1.0.0
rootdir: /builddir/build/BUILD/nikola-8.2.3, configfile: setup.cfg
plugins: cov-4.0.0, anyio-3.5.0
collected 500 items
...
=================================== 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, 185...6\u202fPM UTC' == 'July 10, 185...:34:56 PM UTC'
E         - July 10, 1856 at 12:34:56 PM UTC
E         ?              ^^^         ^
E         + July 10, 1856, 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 at 12:34:56 PM -0400"
E       AssertionError: assert 'July 10, 200...u202fPM -0400' == 'July 10, 200...4:56 PM -0400'
E         - July 10, 2006 at 12:34:56 PM -0400
E         ?              ^^^         ^
E         + July 10, 2006, 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 at 12:34:56 PM UTC'

    @pytest.mark.parametrize(
        "english_variant, expected_date",
        [
            pytest.param("en_US", DT_EN_US, id="US"),
            pytest.param("en_GB", "10 July 1856 at 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, 185...6\u202fPM UTC' == 'July 10, 185...:34:56 PM UTC'
E         - July 10, 1856 at 12:34:56 PM UTC
E         ?              ^^^         ^
E         + July 10, 1856, 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 at 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 at 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, 12:34:56 UTC' == '10 July 1856 at 12:34:56 UTC'
E         - 10 July 1856 at 12:34:56 UTC
E         ?             ^^^
E         + 10 July 1856, 12:34:56 UTC
E         ?             ^

tests/test_locale.py:108: AssertionError

Apart from the at vs , change, there is also a difference in SPACE vs. NARROW NO-BREAK SPACE before PM.

hroncok commented 1 year ago

Thanks.