Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added tests/notebooks/fun-fish.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
128 changes: 128 additions & 0 deletions tests/notebooks/metadata_multiple_image.ipynb

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions tests/test_render_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,18 @@ def test_metadata_image(sphinx_run, clean_doctree, file_regression):
sphinx_run.build()
assert sphinx_run.warnings() == ""
doctree = clean_doctree(sphinx_run.get_resolved_doctree("metadata_image"))
file_regression.check(
doctree.pformat().replace(".jpeg", ".jpg"), extension=".xml", encoding="utf-8"
)
file_regression.check(doctree.pformat(), extension=".xml", encoding="utf8")


@pytest.mark.sphinx_params(
"metadata_multiple_image.ipynb",
conf={"nb_execution_mode": "off", "nb_cell_metadata_key": "myst"},
)
def test_metadata_multiple_image(sphinx_run, clean_doctree, file_regression):
sphinx_run.build()
assert sphinx_run.warnings() == ""
doctree = clean_doctree(sphinx_run.get_resolved_doctree("metadata_multiple_image"))
file_regression.check(doctree.pformat(), extension=".xml", encoding="utf8")


@pytest.mark.sphinx_params(
Expand Down
51 changes: 51 additions & 0 deletions tests/test_render_outputs/test_metadata_multiple_image.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<document source="metadata_multiple_image">
<section ids="formatting-code-outputs" names="formatting\ code\ outputs">
<title>
Formatting code outputs
<paragraph>
This is a test case with multiple captioned and labelled images
<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">
<container classes="cell_input" nb_element="cell_code_source">
<literal_block language="ipython3" linenos="False" xml:space="preserve">
from IPython.display import Image

Image("fun-fish.png")
<container classes="cell_output" nb_element="cell_code_output">
<figure ids="fun-fish" names="fun-fish">
<image alt="fun-fish" candidates="{'*': '_build/jupyter_execute/3eacaf6adad1a4305807616181bbee897bb29177e79e2092ddd0264b848ddb4e.png'}" classes="shadow bg-primary" uri="_build/jupyter_execute/3eacaf6adad1a4305807616181bbee897bb29177e79e2092ddd0264b848ddb4e.png" width="300px">
<caption>
Hey everyone its
<strong>
party
time!
<paragraph>
Link:
<reference internal="True" refid="fun-fish">
<inline classes="std std-ref">
swim to the fish
<paragraph>
Adding another party fish image to test for multiple images
<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">
<container classes="cell_input" nb_element="cell_code_source">
<literal_block language="ipython3" linenos="False" xml:space="preserve">
from IPython.display import Image

Image("fun-fish.png")
<container classes="cell_output" nb_element="cell_code_output">
<figure ids="fun-fish2" names="fun-fish2">
<image alt="fun-fish2" candidates="{'*': '_build/jupyter_execute/3eacaf6adad1a4305807616181bbee897bb29177e79e2092ddd0264b848ddb4e.png'}" classes="shadow bg-primary" uri="_build/jupyter_execute/3eacaf6adad1a4305807616181bbee897bb29177e79e2092ddd0264b848ddb4e.png" width="200px">
<caption>
Hey everyone its
<strong>
party
time again!
<paragraph>
Link:
<reference internal="True" refid="fun-fish">
<inline classes="std std-ref">
swim to the fish
<paragraph>
Link:
<reference internal="True" refid="fun-fish2">
<inline classes="std std-ref">
swim to the fish again