forked from pool/python-Sphinx
* #13000: Drop Python 3.10 support. * #13044: Remove the internal and undocumented has_equations data from the :py:class:`!MathDomain` domain. The undocumented :py:meth:`!MathDomain.has_equations` method now unconditionally returns True. These are replaced by the has_maths_elements key of the page context dict. Patch by Adam Turner. * #13227: HTML output for sequences of keys in the :rst:role:`kbd` role no longer uses a <kbd class="kbd compound"> element to wrap the keys and separators, but places them directly in the relevant parent node. This means that CSS rulesets targeting kbd.compound or .kbd.compound will no longer have any effect. Patch by Adam Turner. * #13037: Deprecate the SingleHTMLBuilder.fix_refuris method. Patch by James Addison. * #13083, #13330: Un-deprecate sphinx.util.import_object. Patch by Matthias Geier. * #13173: Add a new duplicate_declaration warning type, with duplicate_declaration.c and duplicate_declaration.cpp subtypes. Patch by Julien Lecomte and Adam Turner. * #11824: linkcode: Allow extensions to add support for a domain by defining the keys that should be present. Patch by Nicolas Peugnet. * #13144: Add a class option to the :rst:dir:`autosummary` directive. Patch by Tim Hoffmann. * #13146: Napoleon: Unify the type preprocessing logic to allow Google-style docstrings to use the optional and default keywords. Patch by Chris Barrick. * #13227: Implement the :rst:role:`kbd` role as a SphinxRole. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-Sphinx?expand=0&rev=278
225 lines
8.4 KiB
Diff
225 lines
8.4 KiB
Diff
From 5ff3740063c1ac57f17ecd697bcd06cc1de4e75c Mon Sep 17 00:00:00 2001
|
|
From: Adam Turner <9087854+aa-turner@users.noreply.github.com>
|
|
Date: Mon, 6 Jan 2025 06:56:10 +0000
|
|
Subject: [PATCH] Adapt tests for Pygments 2.19
|
|
|
|
---
|
|
tests/test_builders/test_build_html_code.py | 8 +++++++-
|
|
tests/test_builders/test_build_latex.py | 9 +++++++--
|
|
tests/test_directives/test_directive_code.py | 15 +++++++++++++--
|
|
tests/test_extensions/test_ext_viewcode.py | 8 +++++++-
|
|
tests/test_highlighting.py | 2 +-
|
|
tests/test_intl/test_intl.py | 15 +++++++++++++--
|
|
6 files changed, 48 insertions(+), 9 deletions(-)
|
|
|
|
Index: sphinx-8.1.3/tests/test_builders/test_build_html_code.py
|
|
===================================================================
|
|
--- sphinx-8.1.3.orig/tests/test_builders/test_build_html_code.py
|
|
+++ sphinx-8.1.3/tests/test_builders/test_build_html_code.py
|
|
@@ -1,3 +1,4 @@
|
|
+import pygments
|
|
import pytest
|
|
|
|
|
|
@@ -32,11 +33,16 @@ def test_html_codeblock_linenos_style_in
|
|
|
|
@pytest.mark.sphinx('html', testroot='reST-code-role')
|
|
def test_html_code_role(app):
|
|
+ if tuple(map(int, pygments.__version__.split('.')[:2])) >= (2, 19):
|
|
+ sp = '<span class="w"> </span>'
|
|
+ else:
|
|
+ sp = ' '
|
|
+
|
|
app.build()
|
|
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
|
|
|
common_content = (
|
|
- '<span class="k">def</span> <span class="nf">foo</span>'
|
|
+ f'<span class="k">def</span>{sp}<span class="nf">foo</span>'
|
|
'<span class="p">(</span>'
|
|
'<span class="mi">1</span> '
|
|
'<span class="o">+</span> '
|
|
Index: sphinx-8.1.3/tests/test_builders/test_build_latex.py
|
|
===================================================================
|
|
--- sphinx-8.1.3.orig/tests/test_builders/test_build_latex.py
|
|
+++ sphinx-8.1.3/tests/test_builders/test_build_latex.py
|
|
@@ -8,6 +8,7 @@ from pathlib import Path
|
|
from shutil import copyfile
|
|
from subprocess import CalledProcessError
|
|
|
|
+import pygments
|
|
import pytest
|
|
|
|
from sphinx.builders.latex import default_latex_documents
|
|
@@ -2127,12 +2128,16 @@ def test_latex_container(app):
|
|
|
|
@pytest.mark.sphinx('latex', testroot='reST-code-role')
|
|
def test_latex_code_role(app):
|
|
+ if tuple(map(int, pygments.__version__.split('.')[:2])) >= (2, 19):
|
|
+ sp = r'\PYG{+w}{ }'
|
|
+ else:
|
|
+ sp = ' '
|
|
+
|
|
app.build()
|
|
content = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
|
|
|
common_content = (
|
|
- r'\PYG{k}{def} '
|
|
- r'\PYG{n+nf}{foo}'
|
|
+ r'\PYG{k}{def}' + sp + r'\PYG{n+nf}{foo}'
|
|
r'\PYG{p}{(}'
|
|
r'\PYG{l+m+mi}{1} '
|
|
r'\PYG{o}{+} '
|
|
Index: sphinx-8.1.3/tests/test_directives/test_directive_code.py
|
|
===================================================================
|
|
--- sphinx-8.1.3.orig/tests/test_directives/test_directive_code.py
|
|
+++ sphinx-8.1.3/tests/test_directives/test_directive_code.py
|
|
@@ -2,6 +2,7 @@
|
|
|
|
import os.path
|
|
|
|
+import pygments
|
|
import pytest
|
|
from docutils import nodes
|
|
|
|
@@ -393,6 +394,11 @@ def test_literal_include_block_start_wit
|
|
|
|
@pytest.mark.sphinx('html', testroot='directive-code')
|
|
def test_literal_include_linenos(app):
|
|
+ if tuple(map(int, pygments.__version__.split('.')[:2])) >= (2, 19):
|
|
+ sp = '<span class="w"> </span>'
|
|
+ else:
|
|
+ sp = ' '
|
|
+
|
|
app.build(filenames=[app.srcdir / 'linenos.rst'])
|
|
html = (app.outdir / 'linenos.html').read_text(encoding='utf8')
|
|
|
|
@@ -410,7 +416,7 @@ def test_literal_include_linenos(app):
|
|
|
|
# :lines: 5-9
|
|
assert (
|
|
- '<span class="linenos">5</span><span class="k">class</span> '
|
|
+ f'<span class="linenos">5</span><span class="k">class</span>{sp}'
|
|
'<span class="nc">Foo</span><span class="p">:</span>'
|
|
) in html
|
|
|
|
@@ -560,12 +566,17 @@ def test_code_block_highlighted(app):
|
|
|
|
@pytest.mark.sphinx('html', testroot='directive-code')
|
|
def test_linenothreshold(app):
|
|
+ if tuple(map(int, pygments.__version__.split('.')[:2])) >= (2, 19):
|
|
+ sp = '<span class="w"> </span>'
|
|
+ else:
|
|
+ sp = ' '
|
|
+
|
|
app.build(filenames=[app.srcdir / 'linenothreshold.rst'])
|
|
html = (app.outdir / 'linenothreshold.html').read_text(encoding='utf8')
|
|
|
|
# code-block using linenothreshold
|
|
assert (
|
|
- '<span class="linenos">1</span><span class="k">class</span> '
|
|
+ f'<span class="linenos">1</span><span class="k">class</span>{sp}'
|
|
'<span class="nc">Foo</span><span class="p">:</span>'
|
|
) in html
|
|
|
|
Index: sphinx-8.1.3/tests/test_extensions/test_ext_viewcode.py
|
|
===================================================================
|
|
--- sphinx-8.1.3.orig/tests/test_extensions/test_ext_viewcode.py
|
|
+++ sphinx-8.1.3/tests/test_extensions/test_ext_viewcode.py
|
|
@@ -6,6 +6,7 @@ import re
|
|
import shutil
|
|
from typing import TYPE_CHECKING
|
|
|
|
+import pygments
|
|
import pytest
|
|
|
|
if TYPE_CHECKING:
|
|
@@ -13,6 +14,11 @@ if TYPE_CHECKING:
|
|
|
|
|
|
def check_viewcode_output(app: SphinxTestApp) -> str:
|
|
+ if tuple(map(int, pygments.__version__.split('.')[:2])) >= (2, 19):
|
|
+ sp = '<span> </span>'
|
|
+ else:
|
|
+ sp = ' '
|
|
+
|
|
warnings = re.sub(r'\\+', '/', app.warning.getvalue())
|
|
assert re.findall(
|
|
r"index.rst:\d+: WARNING: Object named 'func1' not found in include "
|
|
@@ -41,7 +47,7 @@ def check_viewcode_output(app: SphinxTes
|
|
'<a class="viewcode-back" href="../../index.html#spam.Class1">[docs]</a>\n'
|
|
) in result
|
|
assert '<span>@decorator</span>\n' in result
|
|
- assert '<span>class</span> <span>Class1</span><span>:</span>\n' in result
|
|
+ assert f'<span>class</span>{sp}<span>Class1</span><span>:</span>\n' in result
|
|
assert '<span> </span><span>"""</span>\n' in result
|
|
assert '<span> this is Class1</span>\n' in result
|
|
assert '<span> """</span>\n' in result
|
|
Index: sphinx-8.1.3/tests/test_highlighting.py
|
|
===================================================================
|
|
--- sphinx-8.1.3.orig/tests/test_highlighting.py
|
|
+++ sphinx-8.1.3/tests/test_highlighting.py
|
|
@@ -10,7 +10,7 @@ from pygments.token import Name, Text
|
|
|
|
from sphinx.highlighting import PygmentsBridge
|
|
|
|
-if tuple(map(int, pygments.__version__.split('.')))[:2] < (2, 18):
|
|
+if tuple(map(int, pygments.__version__.split('.')[:2])) < (2, 18):
|
|
from pygments.formatter import Formatter
|
|
|
|
Formatter.__class_getitem__ = classmethod(lambda cls, name: cls) # type: ignore[attr-defined]
|
|
Index: sphinx-8.1.3/tests/test_intl/test_intl.py
|
|
===================================================================
|
|
--- sphinx-8.1.3.orig/tests/test_intl/test_intl.py
|
|
+++ sphinx-8.1.3/tests/test_intl/test_intl.py
|
|
@@ -10,6 +10,7 @@ import shutil
|
|
import time
|
|
from io import StringIO
|
|
|
|
+import pygments
|
|
import pytest
|
|
from babel.messages import mofile, pofile
|
|
from babel.messages.catalog import Catalog
|
|
@@ -1473,6 +1474,11 @@ def test_xml_strange_markup(app):
|
|
@pytest.mark.sphinx('html', testroot='intl')
|
|
@pytest.mark.test_params(shared_result='test_intl_basic')
|
|
def test_additional_targets_should_not_be_translated(app):
|
|
+ if tuple(map(int, pygments.__version__.split('.')[:2])) >= (2, 19):
|
|
+ sp = '<span class="w"> </span>'
|
|
+ else:
|
|
+ sp = ' '
|
|
+
|
|
app.build()
|
|
# [literalblock.txt]
|
|
result = (app.outdir / 'literalblock.html').read_text(encoding='utf8')
|
|
@@ -1511,7 +1517,7 @@ def test_additional_targets_should_not_b
|
|
# doctest block should not be translated but be highlighted
|
|
expected_expr = (
|
|
"""<span class="gp">>>> </span>"""
|
|
- """<span class="kn">import</span> <span class="nn">sys</span> """
|
|
+ f"""<span class="kn">import</span>{sp}<span class="nn">sys</span> """
|
|
"""<span class="c1"># sys importing</span>"""
|
|
)
|
|
assert_count(expected_expr, result, 1)
|
|
@@ -1556,6 +1562,11 @@ def test_additional_targets_should_not_b
|
|
},
|
|
)
|
|
def test_additional_targets_should_be_translated(app):
|
|
+ if tuple(map(int, pygments.__version__.split('.')[:2])) >= (2, 19):
|
|
+ sp = '<span class="w"> </span>'
|
|
+ else:
|
|
+ sp = ' '
|
|
+
|
|
app.build()
|
|
# [literalblock.txt]
|
|
result = (app.outdir / 'literalblock.html').read_text(encoding='utf8')
|
|
@@ -1605,7 +1616,7 @@ def test_additional_targets_should_be_tr
|
|
# doctest block should not be translated but be highlighted
|
|
expected_expr = (
|
|
"""<span class="gp">>>> </span>"""
|
|
- """<span class="kn">import</span> <span class="nn">sys</span> """
|
|
+ f"""<span class="kn">import</span>{sp}<span class="nn">sys</span> """
|
|
"""<span class="c1"># SYS IMPORTING</span>"""
|
|
)
|
|
assert_count(expected_expr, result, 1)
|