Skip to content

Commit 9f46b1f

Browse files
authored
Merge pull request #9557 from tk0miya/pygments
Fix test: Tests has been broken with pygments-2.10+
2 parents e3a8ee9 + bde6c8d commit 9f46b1f

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

tests/test_intl.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import os
1313
import re
1414

15+
import pygments
1516
import pytest
1617
from babel.messages import mofile, pofile
1718
from babel.messages.catalog import Catalog
@@ -30,6 +31,8 @@
3031
},
3132
)
3233

34+
pygments_version = tuple(int(v) for v in pygments.__version__.split('.'))
35+
3336

3437
def read_po(pathname):
3538
with pathname.open() as f:
@@ -1060,8 +1063,13 @@ def test_additional_targets_should_not_be_translated(app):
10601063
assert_count(expected_expr, result, 1)
10611064

10621065
# C code block with lang should not be translated but be *C* highlighted
1063-
expected_expr = ("""<span class="cp">#include</span> """
1064-
"""<span class="cpf">&lt;stdio.h&gt;</span>""")
1066+
if pygments_version < (2, 10, 0):
1067+
expected_expr = ("""<span class="cp">#include</span> """
1068+
"""<span class="cpf">&lt;stdio.h&gt;</span>""")
1069+
else:
1070+
expected_expr = ("""<span class="cp">#include</span>"""
1071+
"""<span class="w"> </span>"""
1072+
"""<span class="cpf">&lt;stdio.h&gt;</span>""")
10651073
assert_count(expected_expr, result, 1)
10661074

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

11401148
# C code block with lang should be translated and be *C* highlighted
1141-
expected_expr = ("""<span class="cp">#include</span> """
1142-
"""<span class="cpf">&lt;STDIO.H&gt;</span>""")
1149+
if pygments_version < (2, 10, 0):
1150+
expected_expr = ("""<span class="cp">#include</span> """
1151+
"""<span class="cpf">&lt;STDIO.H&gt;</span>""")
1152+
else:
1153+
expected_expr = ("""<span class="cp">#include</span>"""
1154+
"""<span class="w"> </span>"""
1155+
"""<span class="cpf">&lt;STDIO.H&gt;</span>""")
11431156
assert_count(expected_expr, result, 1)
11441157

11451158
# literal block in list item should be translated

0 commit comments

Comments
 (0)