@@ -81,6 +81,7 @@ PTESTS_FAST = "\
psmisc \
python3-atomicwrites \
python3-attrs \
+ python3-babel \
python3-bcrypt \
python3-calver \
python3-certifi \
new file mode 100644
@@ -0,0 +1,129 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Tim Orling <tim.orling@konsulko.com>
+Date: Fri, 27 Nov 2026 13:35:47 -0800
+Subject: [PATCH] tests: Make freezegun optional
+
+tests/conftest.py imports freezegun at module level, so the whole test
+suite fails at collection when freezegun is not installed, although
+only a few tests freeze the time.
+
+Import freezegun optionally and skip only the tests that need it, as is
+already done for pytz, jinja2 and setuptools: the frozen_time fixture,
+the frozen part of test_format_time, test_parse_date_two_digit_year,
+and the frontend merge and concat modules, whose autouse fixtures
+freeze the time for every test.
+
+This lets downstream builds run the test suite where freezegun is not
+packaged, such as the OpenEmbedded on-target tests.
+
+Upstream-Status: Submitted [https://github.com/python-babel/babel/pull/1509]
+AI-Generated: Uses Claude Code (Claude Opus 5.5)
+Signed-off-by: Tim Orling <tim.orling@konsulko.com>
+---
+ tests/conftest.py | 8 +++++++-
+ tests/messages/frontend/test_concat.py | 3 ++-
+ tests/messages/frontend/test_merge.py | 3 ++-
+ tests/test_dates.py | 9 ++++++++-
+ 4 files changed, 19 insertions(+), 4 deletions(-)
+
+diff --git a/tests/conftest.py b/tests/conftest.py
+index e1819ff..2146ef5 100644
+--- a/tests/conftest.py
++++ b/tests/conftest.py
+@@ -2,7 +2,11 @@ import datetime
+ import zoneinfo
+
+ import pytest
+-from freezegun import freeze_time
++
++try:
++ from freezegun import freeze_time
++except ModuleNotFoundError:
++ freeze_time = None
+
+ try:
+ import pytz
+@@ -39,5 +43,7 @@ FROZEN_DATETIME = datetime.datetime(1994, 11, 11, 00, 00)
+
+ @pytest.fixture
+ def frozen_time() -> datetime.datetime:
++ if freeze_time is None:
++ pytest.skip("freezegun is not installed")
+ with freeze_time(FROZEN_DATETIME) as frozen:
+ yield frozen.time_to_freeze
+diff --git a/tests/messages/frontend/test_concat.py b/tests/messages/frontend/test_concat.py
+index e55fbc1..4673629 100644
+--- a/tests/messages/frontend/test_concat.py
++++ b/tests/messages/frontend/test_concat.py
+@@ -17,13 +17,14 @@ import pathlib
+ import sys
+
+ import pytest
+-from freezegun import freeze_time
+
+ from babel.messages import Catalog, frontend, pofile
+ from babel.messages.frontend import OptionError
+ from tests.messages.consts import TEST_PROJECT_DISTRIBUTION_DATA
+ from tests.messages.utils import Distribution, run_command, write_po_file
+
++freeze_time = pytest.importorskip("freezegun").freeze_time
++
+
+ @pytest.fixture(autouse=True)
+ def frozen_time():
+diff --git a/tests/messages/frontend/test_merge.py b/tests/messages/frontend/test_merge.py
+index 61c98f1..dc490b5 100644
+--- a/tests/messages/frontend/test_merge.py
++++ b/tests/messages/frontend/test_merge.py
+@@ -17,13 +17,14 @@ import shutil
+ import sys
+
+ import pytest
+-from freezegun import freeze_time
+
+ from babel.messages import Catalog, frontend, pofile
+ from babel.messages.frontend import OptionError
+ from tests.messages.consts import TEST_PROJECT_DISTRIBUTION_DATA
+ from tests.messages.utils import Distribution, run_command, write_po_file
+
++freeze_time = pytest.importorskip("freezegun").freeze_time
++
+
+ @pytest.fixture(autouse=True)
+ def frozen_time():
+diff --git a/tests/test_dates.py b/tests/test_dates.py
+index d9813b8..60435b4 100644
+--- a/tests/test_dates.py
++++ b/tests/test_dates.py
+@@ -13,9 +13,13 @@
+ import calendar
+ from datetime import date, datetime, time, timedelta
+
+-import freezegun
+ import pytest
+
++try:
++ import freezegun
++except ModuleNotFoundError:
++ freezegun = None
++
+ from babel import Locale, dates
+ from babel.dates import NO_INHERITANCE_MARKER, UTC, _localize, parse_pattern
+ from babel.util import FixedOffsetTimezone
+@@ -663,6 +667,8 @@ def test_format_time(timezone_getter):
+ custom = dates.format_time(t, "hh 'o''clock' a, zzzz", tzinfo=eastern, locale='en')
+ assert custom == "09 o'clock AM, Eastern Daylight Time"
+
++ if freezegun is None:
++ pytest.skip("freezegun is not installed")
+ with freezegun.freeze_time("2023-01-01"):
+ t = time(15, 30)
+ paris = dates.format_time(t, format='full', tzinfo=paris, locale='fr_FR')
+@@ -730,6 +736,7 @@ def test_parse_date():
+ ('2090-06-01', '10', 2110),
+ ('2090-06-01', '11', 2011),
+ ])
++@pytest.mark.skipif(freezegun is None, reason="freezegun is not installed")
+ def test_parse_date_two_digit_year(today, yy, expected):
+ with freezegun.freeze_time(today):
+ assert dates.parse_date(f'1/1/{yy}', locale='en_US').year == expected
@@ -10,9 +10,11 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=a2b86daab39fdb8ce59d97e9fecc90ee"
SRC_URI[sha256sum] = "fddd2cbbbac7c299af3c2880be23609c331bd94f0912baca6cb0abfe054dfc27"
-SRC_URI += "file://0001-Fix-required-hatchling-version-1490.patch"
+SRC_URI += "file://0001-Fix-required-hatchling-version-1490.patch \
+ file://0002-tests-make-freezegun-optional.patch \
+ "
-inherit pypi python_hatchling
+inherit pypi python_hatchling ptest-python-pytest
CVE_PRODUCT = "pocoo:babel"
@@ -29,4 +31,22 @@ RDEPENDS:${PN} += "\
python3-zoneinfo \
"
+# The benchmarks are not collected by pytest and need a benchmark plugin.
+# pyproject.toml has the pytest configuration (markers, warning filters),
+# conftest.py keeps pytest out of tests/messages/data and collects the
+# doctests. Some tests read babel/ from the source tree, so link it to the
+# installed package.
+do_install_ptest:append() {
+ rm -rf ${D}${PTEST_PATH}/tests/benchmarks
+ install -m 0644 ${S}/pyproject.toml ${S}/conftest.py ${D}${PTEST_PATH}/
+ ln -sr ${D}${PYTHON_SITEPACKAGES_DIR}/babel ${D}${PTEST_PATH}/babel
+}
+
+# freezegun (meta-python) is optional: the tests that need it are skipped.
+RDEPENDS:${PN}-ptest += "\
+ python3-jinja2 \
+ python3-setuptools \
+ tzdata \
+"
+
BBCLASSEXTEND = "native nativesdk"
Run the upstream test suite with ptest-python-pytest. tests/conftest.py imports freezegun, which is only in meta-python, so patch the tests to skip just the ones that need it. Install the root conftest.py and pyproject.toml for the pytest configuration, and link babel/ to the installed package, since some tests read it from the working directory. All tests pass on qemux86-64 in about 10 seconds, so add it to PTESTS_FAST. AI-Generated: Uses Claude Code (Claude Opus 5.5) Signed-off-by: Tim Orling <tim.orling@konsulko.com> --- .../distro/include/ptest-packagelists.inc | 1 + .../0002-tests-make-freezegun-optional.patch | 129 ++++++++++++++++++ .../python/python3-babel_2.19.0.bb | 24 +++- 3 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 meta/recipes-devtools/python/python3-babel/0002-tests-make-freezegun-optional.patch