Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
hroncok opened this issue Mar 1, 2023 · 1 comment · Fixed by #3668
Closed
Labels

Comments

@hroncok
Copy link

hroncok commented Mar 1, 2023

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 hroncok added the bug label Mar 1, 2023
Kwpolska added a commit that referenced this issue Mar 1, 2023
 Fix #3667 — Adjust test_locale.py to new date formats in babel
@hroncok
Copy link
Author

hroncok commented Mar 1, 2023

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant