Skip to content

Commit 201a48c

Browse files
mmckyagoose77bsipoczpre-commit-ci[bot]
authored
TEST: Adding a test case for multiple captioned figures (#373)
* TEST: Adding a test case for multiple captioned figures * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * MAINT: updating deprecated keywords * Fix typo in filename --------- Co-authored-by: Angus Hollands <goosey15@gmail.com> Co-authored-by: Brigitta Sipőcz <bsipocz@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent adcc42f commit 201a48c

4 files changed

Lines changed: 191 additions & 3 deletions

File tree

tests/notebooks/fun-fish.png

89.9 KB
Loading

tests/notebooks/metadata_multiple_image.ipynb

Lines changed: 128 additions & 0 deletions
Large diffs are not rendered by default.

tests/test_render_outputs.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,18 @@ def test_metadata_image(sphinx_run, clean_doctree, file_regression):
125125
sphinx_run.build()
126126
assert sphinx_run.warnings() == ""
127127
doctree = clean_doctree(sphinx_run.get_resolved_doctree("metadata_image"))
128-
file_regression.check(
129-
doctree.pformat().replace(".jpeg", ".jpg"), extension=".xml", encoding="utf-8"
130-
)
128+
file_regression.check(doctree.pformat(), extension=".xml", encoding="utf8")
129+
130+
131+
@pytest.mark.sphinx_params(
132+
"metadata_multiple_image.ipynb",
133+
conf={"nb_execution_mode": "off", "nb_cell_metadata_key": "myst"},
134+
)
135+
def test_metadata_multiple_image(sphinx_run, clean_doctree, file_regression):
136+
sphinx_run.build()
137+
assert sphinx_run.warnings() == ""
138+
doctree = clean_doctree(sphinx_run.get_resolved_doctree("metadata_multiple_image"))
139+
file_regression.check(doctree.pformat(), extension=".xml", encoding="utf8")
131140

132141

133142
@pytest.mark.sphinx_params(
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<document source="metadata_multiple_image">
2+
<section ids="formatting-code-outputs" names="formatting\ code\ outputs">
3+
<title>
4+
Formatting code outputs
5+
<paragraph>
6+
This is a test case with multiple captioned and labelled images
7+
<container cell_index="1" cell_metadata="{'myst': {'figure': {'caption': 'Hey everyone its **party** time!\n', 'name': 'fun-fish'}, 'image': {'alt': 'fun-fish', 'classes': 'shadow bg-primary', 'width': '300px'}}}" classes="cell" exec_count="1" nb_element="cell_code">
8+
<container classes="cell_input" nb_element="cell_code_source">
9+
<literal_block language="ipython3" linenos="False" xml:space="preserve">
10+
from IPython.display import Image
11+
12+
Image("fun-fish.png")
13+
<container classes="cell_output" nb_element="cell_code_output">
14+
<figure ids="fun-fish" names="fun-fish">
15+
<image alt="fun-fish" candidates="{'*': '_build/jupyter_execute/3eacaf6adad1a4305807616181bbee897bb29177e79e2092ddd0264b848ddb4e.png'}" classes="shadow bg-primary" uri="_build/jupyter_execute/3eacaf6adad1a4305807616181bbee897bb29177e79e2092ddd0264b848ddb4e.png" width="300px">
16+
<caption>
17+
Hey everyone its
18+
<strong>
19+
party
20+
time!
21+
<paragraph>
22+
Link:
23+
<reference internal="True" refid="fun-fish">
24+
<inline classes="std std-ref">
25+
swim to the fish
26+
<paragraph>
27+
Adding another party fish image to test for multiple images
28+
<container cell_index="4" cell_metadata="{'myst': {'figure': {'caption': 'Hey everyone its **party** time again!\n', 'name': 'fun-fish2'}, 'image': {'alt': 'fun-fish2', 'classes': 'shadow bg-primary', 'width': '200px'}}}" classes="cell" exec_count="2" nb_element="cell_code">
29+
<container classes="cell_input" nb_element="cell_code_source">
30+
<literal_block language="ipython3" linenos="False" xml:space="preserve">
31+
from IPython.display import Image
32+
33+
Image("fun-fish.png")
34+
<container classes="cell_output" nb_element="cell_code_output">
35+
<figure ids="fun-fish2" names="fun-fish2">
36+
<image alt="fun-fish2" candidates="{'*': '_build/jupyter_execute/3eacaf6adad1a4305807616181bbee897bb29177e79e2092ddd0264b848ddb4e.png'}" classes="shadow bg-primary" uri="_build/jupyter_execute/3eacaf6adad1a4305807616181bbee897bb29177e79e2092ddd0264b848ddb4e.png" width="200px">
37+
<caption>
38+
Hey everyone its
39+
<strong>
40+
party
41+
time again!
42+
<paragraph>
43+
Link:
44+
<reference internal="True" refid="fun-fish">
45+
<inline classes="std std-ref">
46+
swim to the fish
47+
<paragraph>
48+
Link:
49+
<reference internal="True" refid="fun-fish2">
50+
<inline classes="std std-ref">
51+
swim to the fish again

0 commit comments

Comments
 (0)