python-babel / flask-babel

i18n and l10n support for Flask based on Babel and pytz
https://python-babel.github.io/flask-babel/
Other
432 stars 159 forks source link

Babel 12.2.x test failures due to no-breaking spaces #221

Closed hroncok closed 1 year ago

hroncok commented 1 year ago

Hello, in Fedora we are updating our babel to 12.2.0 and I noticed some test failures of flask-babel. To reproduce:

[flask-babel (master *)]$ git diff
diff --git a/pyproject.toml b/pyproject.toml
index 9538cb9..190cc91 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -32,7 +32,7 @@ include = [
 python = "^3.7"
 pytz = "^2022.7"
 Flask = "^2.0.0"
-Babel = "^2.11.0"
+Babel = "^2.12.0"
 Jinja2 = "^3.1.2"

[flask-babel (master *)]$ poetry install
...
  • Installing babel (2.12.1)
...

[flask-babel (master *)]$ poetry run pytest
============================= test session starts ==============================
platform linux -- Python 3.11.2, pytest-7.2.1, pluggy-1.0.0
rootdir: .../flask-babel
plugins: cov-3.0.0, mock-3.10.0
collected 29 items

tests/test_date_formatting.py F.FF                                       [ 13%]
tests/test_force_locale.py ....                                          [ 27%]
tests/test_gettext.py ............                                       [ 68%]
tests/test_integration.py .......                                        [ 93%]
tests/test_multiple_apps.py .                                            [ 96%]
tests/test_number_formatting.py .                                        [100%]

=================================== FAILURES ===================================
_________________________________ test_basics __________________________________

    def test_basics():
        app = flask.Flask(__name__)
        babel.Babel(app)
        d = datetime(2010, 4, 12, 13, 46)
        delta = timedelta(days=6)

        with app.test_request_context():
>           assert babel.format_datetime(d) == 'Apr 12, 2010, 1:46:00 PM'
E           AssertionError: assert 'Apr 12, 2010...46:00\u202fPM' == 'Apr 12, 2010, 1:46:00 PM'
E             - Apr 12, 2010, 1:46:00 PM
E             ?                      ^
E             + Apr 12, 2010, 1:46:00 PM
E             ?                      ^

tests/test_date_formatting.py:16: AssertionError
_________________________ test_custom_locale_selector __________________________

    def test_custom_locale_selector():
        app = flask.Flask(__name__)
        b = babel.Babel(app)
        d = datetime(2010, 4, 12, 13, 46)

        the_timezone = 'UTC'
        the_locale = 'en_US'

        def select_locale():
            return the_locale

        def select_timezone():
            return the_timezone

        get_babel(app).locale_selector = select_locale
        get_babel(app).timezone_selector = select_timezone

        with app.test_request_context():
>           assert babel.format_datetime(d) == 'Apr 12, 2010, 1:46:00 PM'
E           AssertionError: assert 'Apr 12, 2010...46:00\u202fPM' == 'Apr 12, 2010, 1:46:00 PM'
E             - Apr 12, 2010, 1:46:00 PM
E             ?                      ^
E             + Apr 12, 2010, 1:46:00 PM
E             ?                      ^

tests/test_date_formatting.py:67: AssertionError
_______________________________ test_refreshing ________________________________

    def test_refreshing():
        app = flask.Flask(__name__)
        babel.Babel(app)
        d = datetime(2010, 4, 12, 13, 46)
        with app.test_request_context():
>           assert babel.format_datetime(d) == 'Apr 12, 2010, 1:46:00 PM'
E           AssertionError: assert 'Apr 12, 2010...46:00\u202fPM' == 'Apr 12, 2010, 1:46:00 PM'
E             - Apr 12, 2010, 1:46:00 PM
E             ?                      ^
E             + Apr 12, 2010, 1:46:00 PM
E             ?                      ^

tests/test_date_formatting.py:81: AssertionError
=========================== short test summary info ============================
FAILED tests/test_date_formatting.py::test_basics - AssertionError: assert 'A...
FAILED tests/test_date_formatting.py::test_custom_locale_selector - Assertion...
FAILED tests/test_date_formatting.py::test_refreshing - AssertionError: asser...
========================= 3 failed, 26 passed in 0.16s =========================

This looks like a change from a SPACE to NARROW NO-BREAK SPACE in babel output.

This is just a friendly heads-up for you, I don't expect you to do anything.

SuperSandro2000 commented 1 year ago

FYI #222