Repository: getnikola/nikola

Issue:
Babel 12.2.x test failures due to no-breaking spaces and slightly different output
<!--
Before creating an issue:
* make sure you are using an up-to-date version of Nikola
* search for existing issues that might be related

Make sure to:
* provide information about your environment (below)
* include all the output you get, and any other information related to your problem

Nikola v7.6.4, as provided by Ubuntu, is NOT SUPPORTED.
If you are using this version, you should upgrade: https://getnikola.com/getting-started.html
-->

### 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`.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -132,6 +132,7 @@ def run(self):
                    'Programming Language :: Python :: 3.8',
                    'Programming Language :: Python :: 3.9',
                    'Programming Language :: Python :: 3.10',
+                   'Programming Language :: Python :: 3.11',
                    'Topic :: Internet',
                    'Topic :: Internet :: WWW/HTTP',
                    'Topic :: Text Processing :: Markup'],


Test patch:
diff --git a/tests/test_locale.py b/tests/test_locale.py
--- a/tests/test_locale.py
+++ b/tests/test_locale.py
@@ -13,7 +13,7 @@
 
 TESLA_BIRTHDAY = datetime.date(1856, 7, 10)
 TESLA_BIRTHDAY_DT = datetime.datetime(1856, 7, 10, 12, 34, 56)
-DT_EN_US = "July 10, 1856 at 12:34:56 PM UTC"
+DT_EN_US = "July 10, 1856, 12:34:56\u202fPM UTC"
 DT_PL = "10 lipca 1856 12:34:56 UTC"
 
 
@@ -87,20 +87,20 @@ def test_format_date_timezone(base_config):
         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"
+    assert formatted_date == "July 10, 2006, 12:34:56\u202fPM -0400"
 
     nodst = datetime.datetime(
         2006, 1, 10, 12, 34, 56, tzinfo=dateutil.tz.gettz("America/New_York")
     )
     formatted_date = LocaleBorg().formatted_date("long", nodst)
-    assert formatted_date == "January 10, 2006 at 12:34:56 PM -0500"
+    assert formatted_date == "January 10, 2006, 12:34:56\u202fPM -0500"
 
 
 @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"),
+        pytest.param("en_GB", "10 July 1856, 12:34:56 UTC", id="GB"),
     ],
 )
 def test_format_date_locale_variants(english_variant, expected_date):