Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
NEXT
====

* Fix tests for Python 3.15.0a5+
Patch by Edgar Ramírez-Mondragón

Release 9.1.0 (released Dec 31, 2025)
=====================================

Expand Down
11 changes: 9 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,20 @@ def _init_console(
locale_dir: str | os.PathLike[str] | None = sphinx.locale._LOCALE_DIR,
catalog: str = 'sphinx',
) -> tuple[gettext.NullTranslations, bool]:
"""Monkeypatch ``init_console`` to skip its action.
"""Monkeypatch ``init_console`` to skip locale loading.

Some tests rely on warning messages in English. We don't want
CLI tests to bleed over those tests and make their warnings
translated.

We still register a NullTranslations so that ``__()`` (the console
translation function) returns a plain ``str`` rather than a lazy
``_TranslationProxy``. NullTranslations passes every message through
unchanged, so all strings stay in English.
"""
return gettext.NullTranslations(), False
null = gettext.NullTranslations()
sphinx.locale.translators['console', catalog] = null
return null, False


sphinx.locale.init_console = _init_console
Expand Down
12 changes: 6 additions & 6 deletions tests/test_builders/test_build_linkcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ def test_follows_redirects_on_HEAD(
'index.rst:1: [redirected with Found] '
f'http://{address}/ to http://{address}/?redirected=1\n'
)
assert stderr == textwrap.dedent(
assert strip_escape_sequences(stderr) == textwrap.dedent(
"""\
127.0.0.1 - - [] "HEAD / HTTP/1.1" 302 -
127.0.0.1 - - [] "HEAD /?redirected=1 HTTP/1.1" 204 -
Expand Down Expand Up @@ -749,7 +749,7 @@ def test_follows_redirects_on_GET(
'index.rst:1: [redirected with Found] '
f'http://{address}/ to http://{address}/?redirected=1\n'
)
assert stderr == textwrap.dedent(
assert strip_escape_sequences(stderr) == textwrap.dedent(
"""\
127.0.0.1 - - [] "HEAD / HTTP/1.1" 405 -
127.0.0.1 - - [] "GET / HTTP/1.1" 302 -
Expand Down Expand Up @@ -780,7 +780,7 @@ def test_warns_disallowed_redirects(
'index.rst:1: [redirected with Found] '
f'http://{address}/ to http://{address}/?redirected=1\n'
)
assert stderr == textwrap.dedent(
assert strip_escape_sequences(stderr) == textwrap.dedent(
"""\
127.0.0.1 - - [] "HEAD / HTTP/1.1" 302 -
127.0.0.1 - - [] "HEAD /?redirected=1 HTTP/1.1" 204 -
Expand Down Expand Up @@ -1136,7 +1136,7 @@ def test_too_many_requests_retry_after_int_delay(
rate_limit_log = f'-rate limited- http://{address}/ | sleeping...\n'
assert rate_limit_log in strip_escape_sequences(app.status.getvalue())
_stdout, stderr = capsys.readouterr()
assert stderr == textwrap.dedent(
assert strip_escape_sequences(stderr) == textwrap.dedent(
"""\
127.0.0.1 - - [] "HEAD / HTTP/1.1" 429 -
127.0.0.1 - - [] "HEAD / HTTP/1.1" 200 -
Expand Down Expand Up @@ -1188,7 +1188,7 @@ def test_too_many_requests_retry_after_HTTP_date(
'info': '',
}
_stdout, stderr = capsys.readouterr()
assert stderr == textwrap.dedent(
assert strip_escape_sequences(stderr) == textwrap.dedent(
"""\
127.0.0.1 - - [] "HEAD / HTTP/1.1" 429 -
127.0.0.1 - - [] "HEAD / HTTP/1.1" 200 -
Expand Down Expand Up @@ -1221,7 +1221,7 @@ def test_too_many_requests_retry_after_without_header(
'info': '',
}
_stdout, stderr = capsys.readouterr()
assert stderr == textwrap.dedent(
assert strip_escape_sequences(stderr) == textwrap.dedent(
"""\
127.0.0.1 - - [] "HEAD / HTTP/1.1" 429 -
127.0.0.1 - - [] "HEAD / HTTP/1.1" 200 -
Expand Down
Loading