diff --git a/tests/roots/test-image-glob/conf.py b/tests/roots/test-image-glob/conf.py new file mode 100644 index 000000000..f81c30bc4 --- /dev/null +++ b/tests/roots/test-image-glob/conf.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +master_doc = 'index' diff --git a/tests/roots/test-image-glob/img.gif b/tests/roots/test-image-glob/img.gif new file mode 100644 index 000000000..8f0268655 Binary files /dev/null and b/tests/roots/test-image-glob/img.gif differ diff --git a/tests/roots/test-image-glob/img.pdf b/tests/roots/test-image-glob/img.pdf new file mode 100644 index 000000000..cacbd855d Binary files /dev/null and b/tests/roots/test-image-glob/img.pdf differ diff --git a/tests/roots/test-image-glob/img.png b/tests/roots/test-image-glob/img.png new file mode 100644 index 000000000..4c8f89929 Binary files /dev/null and b/tests/roots/test-image-glob/img.png differ diff --git a/tests/roots/test-image-glob/index.rst b/tests/roots/test-image-glob/index.rst new file mode 100644 index 000000000..6ac4a90ef --- /dev/null +++ b/tests/roots/test-image-glob/index.rst @@ -0,0 +1,14 @@ +test-image-glob +=============== + +.. image:: rimg.png + +.. figure:: rimg.png + + The caption of pic + +.. image:: img.* + +.. figure:: img.* + + The caption of img diff --git a/tests/roots/test-image-glob/rimg.png b/tests/roots/test-image-glob/rimg.png new file mode 100644 index 000000000..1081dc143 Binary files /dev/null and b/tests/roots/test-image-glob/rimg.png differ diff --git a/tests/roots/test-image-glob/subdir/index.rst b/tests/roots/test-image-glob/subdir/index.rst new file mode 100644 index 000000000..f086458d5 --- /dev/null +++ b/tests/roots/test-image-glob/subdir/index.rst @@ -0,0 +1,8 @@ +test-image-glob/subdir +====================== + +.. image:: svgimg.* + +.. figure:: svgimg.* + + The caption of svgimg diff --git a/tests/roots/test-image-glob/subdir/svgimg.pdf b/tests/roots/test-image-glob/subdir/svgimg.pdf new file mode 100644 index 000000000..cacbd855d Binary files /dev/null and b/tests/roots/test-image-glob/subdir/svgimg.pdf differ diff --git a/tests/roots/test-image-glob/subdir/svgimg.svg b/tests/roots/test-image-glob/subdir/svgimg.svg new file mode 100644 index 000000000..10e035b6d --- /dev/null +++ b/tests/roots/test-image-glob/subdir/svgimg.svg @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + Part of the Flat Icon Collection (Thu Aug 26 14:31:40 2004) + + + +
  • + + + + + + </Agent> + </publisher> + <creator + id="creator24"> + <Agent + about="" + id="Agent25"> + <title + id="title26">Danny Allen + + + + + Danny Allen + + + + image/svg+xml + + + + + en + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/tests/test_build.py b/tests/test_build.py index a8a6455b8..6022aaf1a 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -11,6 +11,8 @@ from six import BytesIO +import pickle +from docutils import nodes from textwrap import dedent from sphinx.errors import SphinxError @@ -108,3 +110,47 @@ def test_numbered_circular_toctree(app, status, warning): assert ( 'circular toctree references detected, ignoring: ' 'contents <- sub <- contents') in warnings + + +@with_app(buildername='html', testroot='image-glob') +def test_image_glob(app, status, warning): + app.builder.build_all() + + # index.rst + doctree = pickle.loads((app.doctreedir / 'index.doctree').bytes()) + + assert isinstance(doctree[0][1], nodes.image) + assert doctree[0][1]['candidates'] == {'*': 'rimg.png'} + assert doctree[0][1]['uri'] == 'rimg.png' + + assert isinstance(doctree[0][2], nodes.figure) + assert isinstance(doctree[0][2][0], nodes.image) + assert doctree[0][2][0]['candidates'] == {'*': 'rimg.png'} + assert doctree[0][2][0]['uri'] == 'rimg.png' + + assert isinstance(doctree[0][3], nodes.image) + assert doctree[0][3]['candidates'] == {'application/pdf': 'img.pdf', + 'image/gif': 'img.gif', + 'image/png': 'img.png'} + assert doctree[0][3]['uri'] == 'img.*' + + assert isinstance(doctree[0][4], nodes.figure) + assert isinstance(doctree[0][4][0], nodes.image) + assert doctree[0][4][0]['candidates'] == {'application/pdf': 'img.pdf', + 'image/gif': 'img.gif', + 'image/png': 'img.png'} + assert doctree[0][4][0]['uri'] == 'img.*' + + # subdir/index.rst + doctree = pickle.loads((app.doctreedir / 'subdir/index.doctree').bytes()) + + assert isinstance(doctree[0][1], nodes.image) + assert doctree[0][1]['candidates'] == {'application/pdf': 'subdir/svgimg.pdf', + 'image/svg+xml': 'subdir/svgimg.svg'} + assert doctree[0][1]['uri'] == 'subdir/svgimg.*' + + assert isinstance(doctree[0][2], nodes.figure) + assert isinstance(doctree[0][2][0], nodes.image) + assert doctree[0][2][0]['candidates'] == {'application/pdf': 'subdir/svgimg.pdf', + 'image/svg+xml': 'subdir/svgimg.svg'} + assert doctree[0][2][0]['uri'] == 'subdir/svgimg.*'