Skip to content

Commit

Permalink
Merge pull request sphinx-doc#9557 from tk0miya/pygments
Browse files Browse the repository at this point in the history
Fix test: Tests has been broken with pygments-2.10+
  • Loading branch information
tk0miya committed Aug 21, 2021
2 parents e3a8ee9 + bde6c8d commit 9f46b1f
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions tests/test_intl.py
Expand Up @@ -12,6 +12,7 @@
import os
import re

import pygments
import pytest
from babel.messages import mofile, pofile
from babel.messages.catalog import Catalog
Expand All @@ -30,6 +31,8 @@
},
)

pygments_version = tuple(int(v) for v in pygments.__version__.split('.'))


def read_po(pathname):
with pathname.open() as f:
Expand Down Expand Up @@ -1060,8 +1063,13 @@ def test_additional_targets_should_not_be_translated(app):
assert_count(expected_expr, result, 1)

# C code block with lang should not be translated but be *C* highlighted
expected_expr = ("""<span class="cp">#include</span> """
"""<span class="cpf">&lt;stdio.h&gt;</span>""")
if pygments_version < (2, 10, 0):
expected_expr = ("""<span class="cp">#include</span> """
"""<span class="cpf">&lt;stdio.h&gt;</span>""")
else:
expected_expr = ("""<span class="cp">#include</span>"""
"""<span class="w"> </span>"""
"""<span class="cpf">&lt;stdio.h&gt;</span>""")
assert_count(expected_expr, result, 1)

# literal block in list item should not be translated
Expand Down Expand Up @@ -1138,8 +1146,13 @@ def test_additional_targets_should_be_translated(app):
assert_count(expected_expr, result, 1)

# C code block with lang should be translated and be *C* highlighted
expected_expr = ("""<span class="cp">#include</span> """
"""<span class="cpf">&lt;STDIO.H&gt;</span>""")
if pygments_version < (2, 10, 0):
expected_expr = ("""<span class="cp">#include</span> """
"""<span class="cpf">&lt;STDIO.H&gt;</span>""")
else:
expected_expr = ("""<span class="cp">#include</span>"""
"""<span class="w"> </span>"""
"""<span class="cpf">&lt;STDIO.H&gt;</span>""")
assert_count(expected_expr, result, 1)

# literal block in list item should be translated
Expand Down

0 comments on commit 9f46b1f

Please sign in to comment.