Skip to content

ci: unit test failures due to HTML escaping change #14610

Closed

Description

@jayaddison

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.py

Result:

...
====================================================================== 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">&quot;Hello sphinx world&quot;</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">&quot;Hello sphinx world&quot;</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/A

Additional context

No response

Activity

  1. jayaddison commented on Aug 17, 2026

    @jayaddison
    ContributorAuthor

    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 supported job, which uses a custom dependency version installation strategy, and currently installs an earlier version of Pygments than the other jobs.

  2. jayaddison commented on Aug 18, 2026

    @jayaddison
    ContributorAuthor

    In fact it seems that the following Pygments PR adjusted this output: pygments/pygments#3185

    Credit: #14611 (review)

  3. locked as resolved and limited conversation to collaborators on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions