public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
To: git-commits@fedoraproject.org
Subject: [rpms/python-sphinx] rawhide: Fix tests for pygments 2.21.0+
Date: Wed, 04 Nov 2026 17:16:04 GMT	[thread overview]
Message-ID: <179381256452.1.2928814640243507424.rpms-python-sphinx-73da6393530c@fedoraproject.org> (raw)

A new commit has been pushed.

Repo   : rpms/python-sphinx
Branch : rawhide
Commit : 73da6393530c3c2747ad655be52a717ab9753177
Author : Miro Hrončok <miro@hroncok.cz>
Date   : 2026-11-04T15:37:21+01:00
Stats  : +169/-0 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/python-sphinx/c/73da6393530c3c2747ad655be52a717ab9753177?branch=rawhide

Log:
Fix tests for pygments 2.21.0+

---
diff --git a/b04a21012.patch b/b04a21012.patch
new file mode 100644
index 0000000..bf276b0
--- /dev/null
+++ b/b04a21012.patch
@@ -0,0 +1,166 @@
+From b04a2101295ac3fb725b16111eda0284b6da4cca Mon Sep 17 00:00:00 2001
+From: James Addison <55152140+jayaddison@users.noreply.github.com>
+Date: Fri, 18 Sep 2026 10:38:07 +0100
+Subject: [PATCH] Tests: adapt HTML escaping to pygments v2.21.0
+ change-in-behaviour (#14611)
+
+---
+ tests/test_builders/test_build_html_code.py |  7 ++++++-
+ tests/test_extensions/test_ext_viewcode.py  | 10 ++++++----
+ tests/test_highlighting.py                  | 11 ++++++++---
+ tests/test_intl/test_intl.py                | 18 +++++++++++++++---
+ 4 files changed, 35 insertions(+), 11 deletions(-)
+
+diff --git a/tests/test_builders/test_build_html_code.py b/tests/test_builders/test_build_html_code.py
+index 24a87c07734..19ec291569e 100644
+--- a/tests/test_builders/test_build_html_code.py
++++ b/tests/test_builders/test_build_html_code.py
+@@ -45,6 +45,11 @@ def test_html_code_role(app: SphinxTestApp) -> None:
+     else:
+         sp = ' '
+ 
++    if tuple(map(int, pygments.__version__.split('.')[:2])) >= (2, 21):
++        abc = '"abc"'
++    else:
++        abc = '&quot;abc&quot;'
++
+     app.build()
+     content = (app.outdir / 'index.html').read_text(encoding='utf8')
+ 
+@@ -57,7 +62,7 @@ def test_html_code_role(app: SphinxTestApp) -> None:
+         '<span class="o">+</span> '
+         '<span class="kc">None</span> '
+         '<span class="o">+</span> '
+-        '<span class="s2">&quot;abc&quot;</span>'
++        f'<span class="s2">{abc}</span>'
+         '<span class="p">):</span> '
+         '<span class="k">pass</span>'
+     )
+diff --git a/tests/test_extensions/test_ext_viewcode.py b/tests/test_extensions/test_ext_viewcode.py
+index 03493dda4ff..efb358d5250 100644
+--- a/tests/test_extensions/test_ext_viewcode.py
++++ b/tests/test_extensions/test_ext_viewcode.py
+@@ -20,6 +20,11 @@ def check_viewcode_output(app: SphinxTestApp) -> str:
+     else:
+         sp = ' '
+ 
++    if tuple(map(int, pygments.__version__.split('.')[:2])) >= (2, 21):
++        ds = '"""this is Class1"""'
++    else:
++        ds = '&quot;&quot;&quot;this is Class1&quot;&quot;&quot;'
++
+     warnings = re.sub(r'\\+', '/', app.warning.getvalue())
+     assert re.findall(
+         r"index.rst:\d+: WARNING: Object named 'func1' not found in include "
+@@ -49,10 +54,7 @@ def check_viewcode_output(app: SphinxTestApp) -> str:
+     ) in result
+     assert '<span>@decorator</span>\n' in result
+     assert f'<span>class</span>{sp}<span>Class1</span><span>:</span>\n' in result
+-    assert (
+-        '<span>    </span>'
+-        '<span>&quot;&quot;&quot;this is Class1&quot;&quot;&quot;</span></div>\n'
+-    ) in result
++    assert f'<span>    </span><span>{ds}</span></div>\n' in result
+ 
+     return result
+ 
+diff --git a/tests/test_highlighting.py b/tests/test_highlighting.py
+index 41dd8395f90..1fe1f59347f 100644
+--- a/tests/test_highlighting.py
++++ b/tests/test_highlighting.py
+@@ -26,6 +26,11 @@
+ 
+     Formatter.__class_getitem__ = classmethod(lambda cls, name: cls)  # type: ignore[attr-defined]
+ 
++if tuple(map(int, pygments.__version__.split('.')[:2])) < (2, 21):
++    hsw = '&quot;Hello sphinx world&quot;'
++else:
++    hsw = '"Hello sphinx world"'
++
+ 
+ class MyLexer(RegexLexer):
+     name = 'testlexer'
+@@ -93,7 +98,7 @@ def test_default_highlight(logger: mock.Mock) -> None:
+     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'
++        f'<span class="s2">{hsw}</span>\n</pre></div>\n'
+     )
+ 
+     # default: fallbacks to none if highlighting failed
+@@ -107,7 +112,7 @@ def test_default_highlight(logger: mock.Mock) -> None:
+     assert ret == (
+         '<div class="highlight"><pre><span></span><span class="nb">print</span>'
+         '<span class="p">(</span>'
+-        '<span class="s2">&quot;Hello sphinx world&quot;</span>'
++        f'<span class="s2">{hsw}</span>'
+         '<span class="p">)</span>\n</pre></div>\n'
+     )
+ 
+@@ -116,7 +121,7 @@ def test_default_highlight(logger: mock.Mock) -> None:
+     assert ret == (
+         '<div class="highlight"><pre><span></span><span class="nb">print</span>'
+         '<span class="p">(</span>'
+-        '<span class="s2">&quot;Hello sphinx world&quot;</span>'
++        f'<span class="s2">{hsw}</span>'
+         '<span class="p">)</span>\n</pre></div>\n'
+     )
+ 
+diff --git a/tests/test_intl/test_intl.py b/tests/test_intl/test_intl.py
+index c823a6a3b44..db0598e7e56 100644
+--- a/tests/test_intl/test_intl.py
++++ b/tests/test_intl/test_intl.py
+@@ -1638,6 +1638,11 @@ def test_additional_targets_should_not_be_translated(app: SphinxTestApp) -> None
+     else:
+         sp = ' '
+ 
++    if tuple(map(int, pygments.__version__.split('.')[:2])) >= (2, 21):
++        res = "'result'"
++    else:
++        res = '&#39;result&#39;'
++
+     app.build()
+     # [literalblock.txt]
+     result = (app.outdir / 'literalblock.html').read_text(encoding='utf8')
+@@ -1647,7 +1652,7 @@ def test_additional_targets_should_not_be_translated(app: SphinxTestApp) -> None
+     assert_count(expected_expr, result, 2)
+ 
+     # ruby code block should not be translated but be highlighted
+-    expected_expr = """<span class="s1">&#39;result&#39;</span>"""
++    expected_expr = f"""<span class="s1">{res}</span>"""
+     assert_count(expected_expr, result, 1)
+ 
+     # C code block without lang should not be translated and *ruby* highlighted
+@@ -1726,6 +1731,13 @@ def test_additional_targets_should_be_translated(app: SphinxTestApp) -> None:
+     else:
+         sp = ' '
+ 
++    if tuple(map(int, pygments.__version__.split('.')[:2])) >= (2, 21):
++        home = '"HTTPS://SPHINX-DOC.ORG"'
++        res = "'RESULT'"
++    else:
++        home = '&quot;HTTPS://SPHINX-DOC.ORG&quot;'
++        res = '&#39;RESULT&#39;'
++
+     app.build()
+     # [literalblock.txt]
+     result = (app.outdir / 'literalblock.html').read_text(encoding='utf8')
+@@ -1738,7 +1750,7 @@ def test_additional_targets_should_be_translated(app: SphinxTestApp) -> None:
+     assert_count(expected_expr, result, 1)
+ 
+     # literalinclude should be translated
+-    expected_expr = '<span class="s2">&quot;HTTPS://SPHINX-DOC.ORG&quot;</span>'
++    expected_expr = f'<span class="s2">{home}</span>'
+     assert_count(expected_expr, result, 1)
+ 
+     # title should be translated
+@@ -1746,7 +1758,7 @@ def test_additional_targets_should_be_translated(app: SphinxTestApp) -> None:
+     assert_count(expected_expr, result, 2)
+ 
+     # ruby code block should be translated and be highlighted
+-    expected_expr = """<span class="s1">&#39;RESULT&#39;</span>"""
++    expected_expr = f"""<span class="s1">{res}</span>"""
+     assert_count(expected_expr, result, 1)
+ 
+     # C code block without lang should be translated and *ruby* highlighted

diff --git a/python-sphinx.spec b/python-sphinx.spec
index 43cb9bd..39c9dc0 100644
--- a/python-sphinx.spec
+++ b/python-sphinx.spec
@@ -52,6 +52,9 @@ Patch:      https://github.com/sphinx-doc/sphinx/pull/14507.patch
 # https://github.com/sphinx-doc/sphinx/commit/378a332a8f sans CHANGES.rst
 Patch:      378a332a8f.patch
 
+# Tests: adapt HTML escaping to pygments v2.21.0 change-in-behaviour
+Patch:      https://github.com/sphinx-doc/sphinx/commit/b04a21012.patch
+
 # Make the first party extensions optional
 # This removes the runtime dependencies on:
 #  - sphinxcontrib.applehelp

                 reply	other threads:[~2026-11-04 17:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179381256452.1.2928814640243507424.rpms-python-sphinx-73da6393530c@fedoraproject.org \
    --to=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox