Skip to content

Commit ed97c6e

Browse files
Fix tests for Python 3.15.0a5+
Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
1 parent cc7c6f4 commit ed97c6e

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

CHANGES.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
NEXT
2+
====
3+
4+
* Fix tests for Python 3.15.0a5+
5+
Patch by Edgar Ramírez-Mondragón
6+
17
Release 9.1.0 (released Dec 31, 2025)
28
=====================================
39

tests/conftest.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,20 @@ def _init_console(
2727
locale_dir: str | os.PathLike[str] | None = sphinx.locale._LOCALE_DIR,
2828
catalog: str = 'sphinx',
2929
) -> tuple[gettext.NullTranslations, bool]:
30-
"""Monkeypatch ``init_console`` to skip its action.
30+
"""Monkeypatch ``init_console`` to skip locale loading.
3131
3232
Some tests rely on warning messages in English. We don't want
3333
CLI tests to bleed over those tests and make their warnings
3434
translated.
35+
36+
We still register a NullTranslations so that ``__()`` (the console
37+
translation function) returns a plain ``str`` rather than a lazy
38+
``_TranslationProxy``. NullTranslations passes every message through
39+
unchanged, so all strings stay in English.
3540
"""
36-
return gettext.NullTranslations(), False
41+
null = gettext.NullTranslations()
42+
sphinx.locale.translators['console', catalog] = null
43+
return null, False
3744

3845

3946
sphinx.locale.init_console = _init_console

0 commit comments

Comments
 (0)