Repository navigation
Closed
Labels
Description
Describe the bug
During development of #14241, seemingly unrelated Python unit test failures seem to have begun occurring.
I can replicate these test failures locally on the master branch of Sphinx on my Debian (forky/testing) system, so I do not think that they relate to my changes in that PR.
There are six failures, and they are all cases where the Sphinx unit tests expect certain characters in output HTML to be escaped -- but Sphinx at runtime does not appear to do that any more.
I don't know what caused this to change recently.
How to Reproduce
sphinx $ git checkout e44a40eb2f810558ccd9da1425421270ccb81351
sphinx $ python3 -m venv .venv
sphinx $ source .venv/bin/activate
sphinx $ pip install -e . --group test
sphinx $ pytest tests/test_highlighting.pyResult:
...
====================================================================== FAILURES ======================================================================
_______________________________________________________________ test_default_highlight _______________________________________________________________
logger = <MagicMock name='logger' id='139896650513248'>
@mock.patch('sphinx.highlighting.logger')
def test_default_highlight(logger: mock.Mock) -> None:
bridge = PygmentsBridge('html')
# default: highlights as python3
ret = bridge.highlight_block('print "Hello sphinx world"', 'default')
> assert ret == (
'<div class="highlight"><pre><span></span><span class="nb">print</span> '
'<span class="s2">"Hello sphinx world"</span>\n</pre></div>\n'
)
E assert '<div class=".../pre></div>\n' == '<div class=".../pre></div>\n'
E
E Skipping 78 identical leading characters in diff, use -v to show
E - lass="s2">"Hello sphinx world"</span>
E ? ^^^^^^ ^^^^^^
E + lass="s2">"Hello sphinx world"</span>
E ? ^ ^
E </pre></div>
tests/test_highlighting.py:94: AssertionError
============================================================== short test summary info ===============================================================
FAILED tests/test_highlighting.py::test_default_highlight - assert '<div class=".../pre></div>\n' == '<div class=".../pre></div>\n'
============================================================ 1 failed, 4 passed in 0.42s =============================================================
Environment Information
Platform: linux; (Linux-7.1.8+deb14-amd64-x86_64-with-glibc2.42)
Python version: 3.14.6 (main, Jun 10 2026, 18:54:31) [GCC 15.2.0])
Python implementation: CPython
Sphinx version: 9.1.1+/e44a40eb2
Docutils version: 0.22.4
Jinja2 version: 3.1.6
Pygments version: 2.21.0
Sphinx extensions
N/AAdditional context
No response
Activity
jayaddison commentedon Aug 17, 2026
I think there's a good chance that this relates to a change in the Pygments library, published a few hours ago in the v2.21.0 package: pygments/pygments#3086
In #14611 -- a potential fixup PR -- the only failing CI job is the
Oldest supportedjob, which uses a custom dependency version installation strategy, and currently installs an earlier version of Pygments than the other jobs.jayaddison commentedon Aug 18, 2026
In fact it seems that the following Pygments PR adjusted this output: pygments/pygments#3185
Credit: #14611 (review)