mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix tests for Pygments 2.14
Pygments 2.14 was released on 01/01/2023 [0] [0]: https://pygments.org/docs/changelog/#version-2-14-0
This commit is contained in:
parent
5715abf1d4
commit
965768bfda
@ -62,7 +62,7 @@ dependencies = [
|
|||||||
"sphinxcontrib-serializinghtml>=1.1.5",
|
"sphinxcontrib-serializinghtml>=1.1.5",
|
||||||
"sphinxcontrib-qthelp",
|
"sphinxcontrib-qthelp",
|
||||||
"Jinja2>=3.0",
|
"Jinja2>=3.0",
|
||||||
"Pygments>=2.12",
|
"Pygments>=2.13",
|
||||||
"docutils>=0.18,<0.20",
|
"docutils>=0.18,<0.20",
|
||||||
"snowballstemmer>=2.0",
|
"snowballstemmer>=2.0",
|
||||||
"babel>=2.9",
|
"babel>=2.9",
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
import pygments
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
@ -31,6 +32,16 @@ def test_viewcode(app, status, warning):
|
|||||||
|
|
||||||
result = (app.outdir / '_modules/spam/mod1.html').read_text(encoding='utf8')
|
result = (app.outdir / '_modules/spam/mod1.html').read_text(encoding='utf8')
|
||||||
result = re.sub('<span class=".*?">', '<span>', result) # filter pygments classes
|
result = re.sub('<span class=".*?">', '<span>', result) # filter pygments classes
|
||||||
|
if pygments.__version__ >= '2.14.0':
|
||||||
|
assert ('<div class="viewcode-block" id="Class1"><a class="viewcode-back" '
|
||||||
|
'href="../../index.html#spam.Class1">[docs]</a>'
|
||||||
|
'<span>@decorator</span>\n'
|
||||||
|
'<span>class</span> <span>Class1</span>'
|
||||||
|
'<span>(</span><span>object</span><span>):</span>\n'
|
||||||
|
'<span> </span><span>"""</span>\n'
|
||||||
|
'<span> this is Class1</span>\n'
|
||||||
|
'<span> """</span></div>\n') in result
|
||||||
|
else:
|
||||||
assert ('<div class="viewcode-block" id="Class1"><a class="viewcode-back" '
|
assert ('<div class="viewcode-block" id="Class1"><a class="viewcode-back" '
|
||||||
'href="../../index.html#spam.Class1">[docs]</a>'
|
'href="../../index.html#spam.Class1">[docs]</a>'
|
||||||
'<span>@decorator</span>\n'
|
'<span>@decorator</span>\n'
|
||||||
|
@ -6,6 +6,7 @@ Runs the text builder in the test root.
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
import pygments
|
||||||
import pytest
|
import pytest
|
||||||
from babel.messages import mofile, pofile
|
from babel.messages import mofile, pofile
|
||||||
from babel.messages.catalog import Catalog
|
from babel.messages.catalog import Catalog
|
||||||
@ -1104,8 +1105,11 @@ def test_additional_targets_should_not_be_translated(app):
|
|||||||
expected_expr = ("""<span class="n">literal</span>"""
|
expected_expr = ("""<span class="n">literal</span>"""
|
||||||
"""<span class="o">-</span>"""
|
"""<span class="o">-</span>"""
|
||||||
"""<span class="n">block</span>\n"""
|
"""<span class="n">block</span>\n"""
|
||||||
"""<span class="k">in</span> """
|
"""<span class="k">in</span>"""
|
||||||
|
"""<span class="w"> </span>"""
|
||||||
"""<span class="n">list</span>""")
|
"""<span class="n">list</span>""")
|
||||||
|
if pygments.__version__ < '2.14.0':
|
||||||
|
expected_expr = expected_expr.replace("""<span class="w"> </span>""", ' ')
|
||||||
assert_count(expected_expr, result, 1)
|
assert_count(expected_expr, result, 1)
|
||||||
|
|
||||||
# doctest block should not be translated but be highlighted
|
# doctest block should not be translated but be highlighted
|
||||||
@ -1179,8 +1183,11 @@ def test_additional_targets_should_be_translated(app):
|
|||||||
expected_expr = ("""<span class="no">LITERAL</span>"""
|
expected_expr = ("""<span class="no">LITERAL</span>"""
|
||||||
"""<span class="o">-</span>"""
|
"""<span class="o">-</span>"""
|
||||||
"""<span class="no">BLOCK</span>\n"""
|
"""<span class="no">BLOCK</span>\n"""
|
||||||
"""<span class="no">IN</span> """
|
"""<span class="no">IN</span>"""
|
||||||
|
"""<span class="w"> </span>"""
|
||||||
"""<span class="no">LIST</span>""")
|
"""<span class="no">LIST</span>""")
|
||||||
|
if pygments.__version__ < '2.14.0':
|
||||||
|
expected_expr = expected_expr.replace("""<span class="w"> </span>""", ' ')
|
||||||
assert_count(expected_expr, result, 1)
|
assert_count(expected_expr, result, 1)
|
||||||
|
|
||||||
# doctest block should not be translated but be highlighted
|
# doctest block should not be translated but be highlighted
|
||||||
|
Loading…
Reference in New Issue
Block a user