Skip to content

Commit 1d6b526

Browse files
committed
Adding workaround for tests to pass both <0.22 and 0.22+ docutils
1 parent 0c50da9 commit 1d6b526

20 files changed

Lines changed: 85 additions & 77 deletions

tests/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from nbdime.prettyprint import pretty_print_diff
1717
import nbformat as nbf
1818
import pytest
19+
import docutils
1920
import sphinx
2021
from sphinx import version_info as sphinx_version_info
2122
from sphinx.util.console import nocolor
@@ -304,6 +305,7 @@ class FileRegression:
304305
r"original_uri=\"[^\"]*\"\s",
305306
# TODO: Remove when support for Sphinx<8 is dropped,
306307
re.escape(' translated="True"'),
308+
re.escape(' translated="1"'),
307309
re.escape(" translation_progress=\"{'total': 4, 'translated': 2}\""),
308310
)
309311

@@ -316,4 +318,10 @@ def check(self, data, **kwargs):
316318
def _strip_ignores(self, data):
317319
for ig in self.ignores:
318320
data = re.sub(ig, "", data)
321+
322+
if docutils.__version_info__ < (0, 22):
323+
data = data.replace('linenos="False"', 'linenos="0"')
324+
data = data.replace('nowrap="False"', 'nowrap="0"')
325+
data = data.replace('linenos="True"', 'linenos="1"')
326+
data = data.replace('internal="True"', 'internal="1"')
319327
return data

tests/test_eval/test_sphinx.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
Inline evaluation
55
<container cell_index="1" cell_metadata="{}" classes="cell" exec_count="1" nb_element="cell_code">
66
<container classes="cell_input" nb_element="cell_code_source">
7-
<literal_block language="ipython3" linenos="False" xml:space="preserve">
7+
<literal_block language="ipython3" linenos="0" xml:space="preserve">
88
a = 1
99
<paragraph>
1010
Evaluated inline variable:
1111
<inline classes="output text_plain">
1212
1
13-
<literal_block classes="output text_plain" language="myst-ansi" linenos="False" xml:space="preserve">
13+
<literal_block classes="output text_plain" language="myst-ansi" linenos="0" xml:space="preserve">
1414
1
1515
<container cell_index="3" cell_metadata="{}" classes="cell" exec_count="2" nb_element="cell_code">
1616
<container classes="cell_input" nb_element="cell_code_source">
17-
<literal_block language="ipython3" linenos="False" xml:space="preserve">
17+
<literal_block language="ipython3" linenos="0" xml:space="preserve">
1818
import base64
1919
from IPython.display import Image
2020
string = "iVBORw0KGgoAAAANSUhEUgAAAHQAAAB0CAYAAABUmhYnAAAEd0lEQVR4Xu2c0ZLjIAwEk///6GzVvZlspWtWksNRnVcwiGmNwHaS5+v1ej38HKPAU6DHsPy3EIGexVOgh/EUqEBPU+Cw9biHCvQwBQ5bjg4V6GEKHLYcHSrQwxQ4bDk6VKCHKXDYcnSoQA9T4LDllB36fD5vlWR9fUvz0+ve9fp0/O7FU7w0n0CXhBSoDiXTRO06FBKKBLLkLvlGgkTp+UvndPzu/ul46Xq7x2/fQ8kR0wtOBaL+1J6uZ+3fPb5Aw0PRtxOWEkigAr3mCJUMuk9cM45uG3ZvJwel8dN4byW8+r1cgWYPVgRaLIlpwqWCT1cgHbr8skOgYUqkgtHwVYfQKZTiTW8rdCgQFWjtt2Pjty3TGdztOB0aHlosuVcHpglJ+h3nUFow7bE6dDOHCjRN2fBty917qEAF+jEHaI+bTlhK0Nsf/aUBpXtYdXy6noDS9dTePf74oYgWRO3dC6b57k6o7vUJFAh3Cz6dMAIV6FWB9FCQlry1f/ejQXLgt9eX6tXu0DSAtL9APysm0OYHI2mCUgVKxxOoQNOcubc/7XnF5yj3LuYPs5Ud+oc5Ry8R6GEpK1CBjlaMuwcvl1xyBC2I8im9T0xva6pPbtL1V+MjPQW6KEQJRAlAggs0vK2oCibQ4g9+LbnXb96THlQBvl5y0yclqYNQAKgAVGIJQHWPpfjf4uv+bUsagECvClCCkL46VIdecyQtKZRhlKGW3OG3LekeQ0DSBOk+1VLCdbdTAqfzlUuuQFPJe/fM9kORQAV6UYBKJslF11NJS0s8xZO2U3zpeO0lNw2g2+HV8dLbKJov1aMKWKDFfyITKKRsegqmjE7H06FpTRHoRwUoQUnu9pJLh4z0EFMdjwRI46ESWwVC8VK7QMN/TRHookDqCB1Knry261AdmmXMdG86xabzd49H83fP1+5QWkB3e7sg4eu06nra46++4K4uqHp9uyACrSKpXS/Q5kMRnUJruN6vnr7Po/VMn9KrepX3UBKgGmD1UVw6P61HoKmi0F+HfhZIhy766NDhU2F66CEgzQXjQRUjjb8aX7tDaYFpwKkgAi0SSAUXaO0Pjkk/HUoKFQ9p0wm/hjcONC2B6W3B24KKv1ZLx0vzgfQoFsyHQJe3LQINHUEZrUNre6wO1aHLw+AvO5QOHdReLbE0/vSeedyhKBWUDh00XpoAAg2/EkIAqD0FlPYXqEDp3Pix/b8/FKUOIMem7fR6j8Yr0fvlYoEWK4JAw0dplOE6dLnrqH5JrCp4NcMFejPQ6h7RnTAUT/eTKkpYiidtH99D04C6bwvS+QX65W8sUMkVaKgAlcRwuLfuNL5Ah/fQKkC6Pi2JKXB6NEjxUTslKF1P7e17KE1YbRfoZwUFuuijQ4v/l5s6VocOOzQFYv9ZBcoldzY8R08VEGiq2Ob9Bbo5oDQ8gaaKbd5foJsDSsMTaKrY5v0FujmgNDyBpopt3l+gmwNKwxNoqtjm/QW6OaA0PIGmim3eX6CbA0rDE2iq2Ob9Bbo5oDS8H8eCMw7yCzx+AAAAAElFTkSuQmCC"

tests/test_execute/test_complex_outputs_unrun_auto.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195
<literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve">
196196
<IPython.core.display.Latex object>
197197
<container mime_type="text/latex">
198-
<math_block classes="output text_latex" nowrap="False" number="True" xml:space="preserve">
198+
<math_block classes="output text_latex" nowrap="0" number="True" xml:space="preserve">
199199
a = b+c
200200
<paragraph>
201201
The plotting code for a sympy equation (=@eqn:example_sympy).
@@ -216,7 +216,7 @@
216216
<container mime_type="image/png">
217217
<image candidates="{'*': '_build/jupyter_execute/e2dfbe330154316cfb6f3186e8f57fc4df8aee03b0303ed1345fc22cd51f66de.png'}" uri="_build/jupyter_execute/e2dfbe330154316cfb6f3186e8f57fc4df8aee03b0303ed1345fc22cd51f66de.png">
218218
<container mime_type="text/latex">
219-
<math_block classes="output text_latex" nowrap="False" number="True" xml:space="preserve">
219+
<math_block classes="output text_latex" nowrap="0" number="True" xml:space="preserve">
220220
\displaystyle \left(\sqrt{5} i\right)^{\alpha} \left(\frac{1}{2} - \frac{2 \sqrt{5} i}{5}\right) + \left(- \sqrt{5} i\right)^{\alpha} \left(\frac{1}{2} + \frac{2 \sqrt{5} i}{5}\right)
221221
<section ids="interactive-outputs" names="interactive\ outputs">
222222
<title>

tests/test_execute/test_complex_outputs_unrun_cache.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195
<literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve">
196196
<IPython.core.display.Latex object>
197197
<container mime_type="text/latex">
198-
<math_block classes="output text_latex" nowrap="False" number="True" xml:space="preserve">
198+
<math_block classes="output text_latex" nowrap="0" number="True" xml:space="preserve">
199199
a = b+c
200200
<paragraph>
201201
The plotting code for a sympy equation (=@eqn:example_sympy).
@@ -216,7 +216,7 @@
216216
<container mime_type="image/png">
217217
<image candidates="{'*': '_build/jupyter_execute/e2dfbe330154316cfb6f3186e8f57fc4df8aee03b0303ed1345fc22cd51f66de.png'}" uri="_build/jupyter_execute/e2dfbe330154316cfb6f3186e8f57fc4df8aee03b0303ed1345fc22cd51f66de.png">
218218
<container mime_type="text/latex">
219-
<math_block classes="output text_latex" nowrap="False" number="True" xml:space="preserve">
219+
<math_block classes="output text_latex" nowrap="0" number="True" xml:space="preserve">
220220
\displaystyle \left(\sqrt{5} i\right)^{\alpha} \left(\frac{1}{2} - \frac{2 \sqrt{5} i}{5}\right) + \left(- \sqrt{5} i\right)^{\alpha} \left(\frac{1}{2} + \frac{2 \sqrt{5} i}{5}\right)
221221
<section ids="interactive-outputs" names="interactive\ outputs">
222222
<title>

tests/test_glue/test_parser.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@
44
Glue Tests
55
<container cell_index="1" cell_metadata="{}" classes="cell" exec_count="1" nb_element="cell_code">
66
<container classes="cell_input" nb_element="cell_code_source">
7-
<literal_block language="ipython3" linenos="False" xml:space="preserve">
7+
<literal_block language="ipython3" linenos="0" xml:space="preserve">
88
from myst_nb import glue
99
<container cell_index="2" cell_metadata="{}" classes="cell" exec_count="2" nb_element="cell_code">
1010
<container classes="cell_input" nb_element="cell_code_source">
11-
<literal_block language="ipython3" linenos="False" xml:space="preserve">
11+
<literal_block language="ipython3" linenos="0" xml:space="preserve">
1212
glue("key_text1", "text1")
1313
glue("key_float", 3.14159)
1414
<container classes="cell_output" nb_element="cell_code_output">
15-
<literal_block classes="output text_plain" language="myst-ansi" linenos="False" xml:space="preserve">
15+
<literal_block classes="output text_plain" language="myst-ansi" linenos="0" xml:space="preserve">
1616
'text1'
17-
<literal_block classes="output text_plain" language="myst-ansi" linenos="False" xml:space="preserve">
17+
<literal_block classes="output text_plain" language="myst-ansi" linenos="0" xml:space="preserve">
1818
3.14159
1919
<container cell_index="3" cell_metadata="{}" classes="cell" exec_count="3" nb_element="cell_code">
2020
<container classes="cell_input" nb_element="cell_code_source">
21-
<literal_block language="ipython3" linenos="False" xml:space="preserve">
21+
<literal_block language="ipython3" linenos="0" xml:space="preserve">
2222
glue("key_undisplayed", "undisplayed", display=False)
2323
<container cell_index="4" cell_metadata="{'scrolled': True}" classes="cell" exec_count="4" nb_element="cell_code">
2424
<container classes="cell_input" nb_element="cell_code_source">
25-
<literal_block language="ipython3" linenos="False" xml:space="preserve">
25+
<literal_block language="ipython3" linenos="0" xml:space="preserve">
2626
import pandas as pd
2727

2828
df = pd.DataFrame({"header": [1, 2, 3]})
@@ -68,7 +68,7 @@
6868
</div>
6969
<container cell_index="5" cell_metadata="{}" classes="cell" exec_count="5" nb_element="cell_code">
7070
<container classes="cell_input" nb_element="cell_code_source">
71-
<literal_block language="ipython3" linenos="False" xml:space="preserve">
71+
<literal_block language="ipython3" linenos="0" xml:space="preserve">
7272
import matplotlib.pyplot as plt
7373

7474
plt.plot([1, 2, 3])
@@ -149,7 +149,7 @@
149149
Math
150150
<container cell_index="8" cell_metadata="{}" classes="cell" exec_count="6" nb_element="cell_code">
151151
<container classes="cell_input" nb_element="cell_code_source">
152-
<literal_block language="ipython3" linenos="False" xml:space="preserve">
152+
<literal_block language="ipython3" linenos="0" xml:space="preserve">
153153
import sympy as sym
154154

155155
f = sym.Function("f")
@@ -158,8 +158,8 @@
158158
f = y(n) - 2 * y(n - 1 / sym.pi) - 5 * y(n - 2)
159159
glue("sym_eq", sym.rsolve(f, y(n), [1, 4]))
160160
<container classes="cell_output" nb_element="cell_code_output">
161-
<math_block classes="output text_latex" nowrap="False" number="True" xml:space="preserve">
161+
<math_block classes="output text_latex" nowrap="0" number="True" xml:space="preserve">
162162
\displaystyle \left(\sqrt{5} i\right)^{\alpha} \left(\frac{1}{2} - \frac{2 \sqrt{5} i}{5}\right) + \left(- \sqrt{5} i\right)^{\alpha} \left(\frac{1}{2} + \frac{2 \sqrt{5} i}{5}\right)
163163
<target refid="equation-eq-sym">
164-
<math_block classes="pasted-math" docname="with_glue" ids="equation-eq-sym" label="eq-sym" nowrap="False" number="1" xml:space="preserve">
164+
<math_block classes="pasted-math" docname="with_glue" ids="equation-eq-sym" label="eq-sym" nowrap="0" number="1" xml:space="preserve">
165165
\displaystyle \left(\sqrt{5} i\right)^{\alpha} \left(\frac{1}{2} - \frac{2 \sqrt{5} i}{5}\right) + \left(- \sqrt{5} i\right)^{\alpha} \left(\frac{1}{2} + \frac{2 \sqrt{5} i}{5}\right)

tests/test_parser/test_complex_outputs.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@
201201
</table>
202202
</div>
203203
<container mime_type="text/latex">
204-
<math_block classes="output text_latex" nowrap="False" number="True" xml:space="preserve">
204+
<math_block classes="output text_latex" nowrap="0" number="True" xml:space="preserve">
205205
\begin{tabular}{lllrr}
206206
\toprule
207207
{} & a & b & c & d \\
@@ -227,7 +227,7 @@
227227
<container classes="cell_output" nb_element="cell_code_output">
228228
<container nb_element="mime_bundle">
229229
<container mime_type="text/latex">
230-
<math_block classes="output text_latex" nowrap="False" number="True" xml:space="preserve">
230+
<math_block classes="output text_latex" nowrap="0" number="True" xml:space="preserve">
231231
a = b+c
232232
<container mime_type="text/plain">
233233
<literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve">
@@ -246,7 +246,7 @@
246246
<container mime_type="image/png">
247247
<image candidates="{'*': '_build/jupyter_execute/8c43e5c8cccf697754876b7fec1b0a9b731d7900bb585e775a5fa326b4de8c5a.png'}" uri="_build/jupyter_execute/8c43e5c8cccf697754876b7fec1b0a9b731d7900bb585e775a5fa326b4de8c5a.png">
248248
<container mime_type="text/latex">
249-
<math_block classes="output text_latex" nowrap="False" number="True" xml:space="preserve">
249+
<math_block classes="output text_latex" nowrap="0" number="True" xml:space="preserve">
250250
\displaystyle \left(\sqrt{5} i\right)^{\alpha} \left(\frac{1}{2} - \frac{2 \sqrt{5} i}{5}\right) + \left(- \sqrt{5} i\right)^{\alpha} \left(\frac{1}{2} + \frac{2 \sqrt{5} i}{5}\right)
251251
<container mime_type="text/plain">
252252
<literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve">

tests/test_render_outputs/test_basic_run.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
some text
77
<container cell_index="1" cell_metadata="{}" classes="cell" exec_count="1" nb_element="cell_code">
88
<container classes="cell_input" nb_element="cell_code_source">
9-
<literal_block language="ipython3" linenos="False" xml:space="preserve">
9+
<literal_block language="ipython3" linenos="0" xml:space="preserve">
1010
a = 1
1111
print(a)
1212
<container classes="cell_output" nb_element="cell_code_output">
13-
<literal_block classes="output stream" language="myst-ansi" linenos="False" xml:space="preserve">
13+
<literal_block classes="output stream" language="myst-ansi" linenos="0" xml:space="preserve">
1414
1

0 commit comments

Comments
 (0)