mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #9557 from tk0miya/pygments
Fix test: Tests has been broken with pygments-2.10+
This commit is contained in:
commit
9f46b1fa67
@ -12,6 +12,7 @@
|
|||||||
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
|
||||||
@ -30,6 +31,8 @@ sphinx_intl = pytest.mark.sphinx(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
pygments_version = tuple(int(v) for v in pygments.__version__.split('.'))
|
||||||
|
|
||||||
|
|
||||||
def read_po(pathname):
|
def read_po(pathname):
|
||||||
with pathname.open() as f:
|
with pathname.open() as f:
|
||||||
@ -1060,8 +1063,13 @@ def test_additional_targets_should_not_be_translated(app):
|
|||||||
assert_count(expected_expr, result, 1)
|
assert_count(expected_expr, result, 1)
|
||||||
|
|
||||||
# C code block with lang should not be translated but be *C* highlighted
|
# C code block with lang should not be translated but be *C* highlighted
|
||||||
|
if pygments_version < (2, 10, 0):
|
||||||
expected_expr = ("""<span class="cp">#include</span> """
|
expected_expr = ("""<span class="cp">#include</span> """
|
||||||
"""<span class="cpf"><stdio.h></span>""")
|
"""<span class="cpf"><stdio.h></span>""")
|
||||||
|
else:
|
||||||
|
expected_expr = ("""<span class="cp">#include</span>"""
|
||||||
|
"""<span class="w"> </span>"""
|
||||||
|
"""<span class="cpf"><stdio.h></span>""")
|
||||||
assert_count(expected_expr, result, 1)
|
assert_count(expected_expr, result, 1)
|
||||||
|
|
||||||
# literal block in list item should not be translated
|
# literal block in list item should not be translated
|
||||||
@ -1138,8 +1146,13 @@ def test_additional_targets_should_be_translated(app):
|
|||||||
assert_count(expected_expr, result, 1)
|
assert_count(expected_expr, result, 1)
|
||||||
|
|
||||||
# C code block with lang should be translated and be *C* highlighted
|
# C code block with lang should be translated and be *C* highlighted
|
||||||
|
if pygments_version < (2, 10, 0):
|
||||||
expected_expr = ("""<span class="cp">#include</span> """
|
expected_expr = ("""<span class="cp">#include</span> """
|
||||||
"""<span class="cpf"><STDIO.H></span>""")
|
"""<span class="cpf"><STDIO.H></span>""")
|
||||||
|
else:
|
||||||
|
expected_expr = ("""<span class="cp">#include</span>"""
|
||||||
|
"""<span class="w"> </span>"""
|
||||||
|
"""<span class="cpf"><STDIO.H></span>""")
|
||||||
assert_count(expected_expr, result, 1)
|
assert_count(expected_expr, result, 1)
|
||||||
|
|
||||||
# literal block in list item should be translated
|
# literal block in list item should be translated
|
||||||
|
Loading…
Reference in New Issue
Block a user