1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
From: Dmitry Shachnev <mitya57@debian.org>
Date: Wed, 1 Oct 2025 01:38:22 +0300
Subject: Make the tests pass with Docutils 0.22
Docutils now normalizes boolean values using str(int(value)):
https://sourceforge.net/p/docutils/code/9691/
(cherry picked from commit 338ecee3f6c03a9fb541096725bf2ea657ebd9cd)
---
texext/tests/test_plotdirective.py | 13 ++++++++-----
texext/tests/test_tinypages.py | 7 +++++--
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/texext/tests/test_plotdirective.py b/texext/tests/test_plotdirective.py
index 3b4ded8..66be301 100644
--- a/texext/tests/test_plotdirective.py
+++ b/texext/tests/test_plotdirective.py
@@ -6,12 +6,14 @@ Test ability to combine plot_directive with mathcode
from os.path import dirname, join as pjoin
import re
+import docutils
import sphinx
SPHINX_ge_8p2 = sphinx.version_info[:2] >= (8, 2)
SPHINX_ge_1p8 = sphinx.version_info[:2] >= (1, 8)
SPHINX_ge_1p7 = sphinx.version_info[:2] >= (1, 7)
SPHINX_ge_1p5 = sphinx.version_info[:2] >= (1, 5)
+DOCUTILS_ge_0p22 = docutils.__version_info__ >= (0, 22)
from sphinxtesters import PageBuilder
@@ -26,11 +28,12 @@ def format_math_block(name, latex, label=None, number=None,
number = 'True' if number is None else number
label = 'True' if label is None else label
id_part = '' if ids is None else 'ids="{}" '.format(ids)
- nowrap = 'no-wrap="False" ' if SPHINX_ge_8p2 else ''
+ false = "0" if DOCUTILS_ge_0p22 else "False"
+ nowrap = f'no-wrap="{false}" ' if SPHINX_ge_8p2 else ''
return (
- '<math_block docname="{}" {}label="{}" '
- '{}nowrap="False" number="{}" xml:space="preserve">{}'
- '</math_block>'.format(name, id_part, label, nowrap, number, latex)
+ f'<math_block docname="{name}" {id_part}label="{label}" '
+ f'{nowrap}nowrap="{false}" number="{number}" '
+ f'xml:space="preserve">{latex}</math_block>'
)
number = 'None' if number is None else number
label = 'None' if label is None else label
@@ -47,7 +50,7 @@ EXP_PLOT_AND_MATH = (
'<title>Plot directive with mathcode</title>\n'
'<paragraph>Some text</paragraph>\n'
r'<literal_block '
- '(force="False" )?'
+ f'(force="{0 if DOCUTILS_ge_0p22 else False}" )?'
'(highlight_args="{}" )?'
'language="python" '
'(linenos="False" )?'
diff --git a/texext/tests/test_tinypages.py b/texext/tests/test_tinypages.py
index 156e4b4..d3dd802 100644
--- a/texext/tests/test_tinypages.py
+++ b/texext/tests/test_tinypages.py
@@ -2,9 +2,11 @@
from os.path import (join as pjoin, dirname, isdir)
+import docutils
import sphinx
SPHINX_ge_1p5 = sphinx.version_info[:2] >= (1, 5)
SPHINX_ge_1p8 = sphinx.version_info[:2] >= (1, 8)
+DOCUTILS_ge_0p22 = docutils.__version_info__ >= (0, 22)
from sphinxtesters import PageBuilder
@@ -41,8 +43,9 @@ class TestTinyPages(PageBuilder):
back_ref = (
'<paragraph>Refers to equation at '
'<pending_xref refdoc="some_math" refdomain="math" '
- 'refexplicit="False" reftarget="some-label" '
- 'reftype="eq" refwarn="True">'
+ f'refexplicit="{0 if DOCUTILS_ge_0p22 else False}" '
+ 'reftarget="some-label" reftype="eq" '
+ f'refwarn="{1 if DOCUTILS_ge_0p22 else True}">'
'<literal classes="xref eq">some-label</literal>'
'</pending_xref>')
else:
|