From 2f8bb9a15531f7ffd5526b588e90e56fc78e1346 Mon Sep 17 00:00:00 2001 From: Tomas Roun Date: Tue, 10 Nov 2026 21:53:44 +0100 Subject: [PATCH 1/4] ci: Use PyPy 3.11 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b31f805b..c9c51d600 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,7 +61,7 @@ jobs: - "3.13" - "3.14" - "3.15" - - "pypy3.10" + - "pypy3.11" env: BABEL_CLDR_NO_DOWNLOAD_PROGRESS: "1" BABEL_CLDR_QUIET: "1" From 306ef37a7b36a9e1d873288ef6b702a70bddbd02 Mon Sep 17 00:00:00 2001 From: Tomas Roun Date: Tue, 10 Nov 2026 23:08:31 +0100 Subject: [PATCH 2/4] Fix test_setuptools_commands on PyPy Some doctests, like `core.default_locale` modify os.environ, including setting a different locale, without proper cleanup. When a PyPy subprocess spawned by `test_setuptools_commands` tries to set the non-existent locale, it crashes which makes the test fail. This PR adds a cleanup fixture that restores os.environ after every test. --- conftest.py | 12 ++++++++++++ tests/messages/test_setuptools_frontend.py | 7 ------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/conftest.py b/conftest.py index 015a20440..7c2af3855 100644 --- a/conftest.py +++ b/conftest.py @@ -1,5 +1,7 @@ +import os from pathlib import Path +import pytest from _pytest.doctest import DoctestModule collect_ignore = [ @@ -21,3 +23,13 @@ def _is_relative(p1: Path, p2: Path) -> bool: def pytest_collect_file(file_path: Path, parent): if _is_relative(file_path, babel_path) and file_path.suffix == '.py': return DoctestModule.from_parent(parent, path=file_path) + + +@pytest.fixture(autouse=True) +def restore_environ(): + # Clean up after after tests that modify environment + # variables (e.g. core.default_locale doctest) + saved = os.environ.copy() + yield + os.environ.clear() + os.environ.update(saved) diff --git a/tests/messages/test_setuptools_frontend.py b/tests/messages/test_setuptools_frontend.py index d74c8e7a7..b55e8e3e8 100644 --- a/tests/messages/test_setuptools_frontend.py +++ b/tests/messages/test_setuptools_frontend.py @@ -48,13 +48,6 @@ def test_extract_distutils_keyword_arg_388(kwarg, expected): assert set(cmdinst.add_comments) == {"Bar", "Foo"} -@pytest.mark.xfail( - # Python 3.10.16[pypy-7.3.19-final] in GHA fails with "unsupported locale setting" - # in the subprocesses this test spawns. Hard to say why because it doesn't do that - # locally. - condition=(sys.implementation.name == "pypy" and "BABEL_TOX_INI_DIR" in os.environ), - reason="Test will likely fail with 'unsupported locale setting' in subprocesses; see comment", -) def test_setuptools_commands(tmp_path, monkeypatch): """ Smoke-tests all of the setuptools versions of the commands in turn. From 654ae650b3294d13f16a7b780d7f6d4902ad8fa4 Mon Sep 17 00:00:00 2001 From: "Tomas R." Date: Thu, 12 Nov 2026 20:37:50 +0100 Subject: [PATCH 3/4] Include pypy312 Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9c51d600..0a504e9ed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,6 +62,7 @@ jobs: - "3.14" - "3.15" - "pypy3.11" + - "pypy3.12" env: BABEL_CLDR_NO_DOWNLOAD_PROGRESS: "1" BABEL_CLDR_QUIET: "1" From c5b4b8dc2cfa1d3c82c561b76fa222fa7db98ed0 Mon Sep 17 00:00:00 2001 From: Tomas Roun Date: Thu, 12 Nov 2026 20:51:30 +0100 Subject: [PATCH 4/4] Only restore environ for doctests --- conftest.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/conftest.py b/conftest.py index 7c2af3855..4ed891ccd 100644 --- a/conftest.py +++ b/conftest.py @@ -1,8 +1,9 @@ import os from pathlib import Path +from unittest import mock import pytest -from _pytest.doctest import DoctestModule +from _pytest.doctest import DoctestItem, DoctestModule collect_ignore = [ 'babel/messages/setuptools_frontend.py', @@ -26,10 +27,11 @@ def pytest_collect_file(file_path: Path, parent): @pytest.fixture(autouse=True) -def restore_environ(): - # Clean up after after tests that modify environment - # variables (e.g. core.default_locale doctest) - saved = os.environ.copy() - yield - os.environ.clear() - os.environ.update(saved) +def _isolate_doctest_environ(request): + # Clean up after after doctests that modify environment + # variables (e.g. core.default_locale) + if isinstance(request.node, DoctestItem): + with mock.patch.dict(os.environ): + yield + else: + yield