python-sphinx/fix-tests-with-pygments-210.patch
2021-08-18 12:39:04 +02:00

63 lines
2.4 KiB
Diff

From 06ec5b027d01e8f7717e4687f89f335e83545ff9 Mon Sep 17 00:00:00 2001
From: Takeshi KOMIYA <i.tkomiya@gmail.com>
Date: Wed, 18 Aug 2021 01:50:08 +0900
Subject: [PATCH] Fix test: Tests has been broken with pygments-2.10+
---
tests/test_intl.py | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/tests/test_intl.py b/tests/test_intl.py
index 7791b4aeed5..e9e7ee9e24b 100644
--- a/tests/test_intl.py
+++ b/tests/test_intl.py
@@ -12,6 +12,7 @@
import os
import re
+import pygments
import pytest
from babel.messages import mofile, pofile
from babel.messages.catalog import Catalog
@@ -30,6 +31,8 @@
},
)
+pygments_version = tuple(int(v) for v in pygments.__version__.split('.'))
+
def read_po(pathname):
with pathname.open() as f:
@@ -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
@@ -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