Fix the handling of images in different directories.

This commit is contained in:
Georg Brandl
2008-11-06 10:36:56 +01:00
parent 27ee1ed5d4
commit dbfe74d5e6
6 changed files with 28 additions and 16 deletions

View File

@@ -18,3 +18,6 @@ Sphinx image handling
.. a non-local image URI
.. image:: http://www.python.org/logo.png
.. an image with subdir and unspecified extension
.. image:: subdir/simg.*

BIN
tests/root/subdir/simg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

View File

@@ -27,7 +27,7 @@ latex_warnfile = StringIO()
ENV_WARNINGS = """\
WARNING: %(root)s/images.txt:9: Image file not readable: foo.png
WARNING: %(root)s/images.txt:20: Nonlocal image URI found: http://www.python.org/logo.png
WARNING: %(root)s/images.txt:21: Nonlocal image URI found: http://www.python.org/logo.png
WARNING: %(root)s/includes.txt:: (WARNING/2) Encoding 'utf-8' used for reading included \
file u'wrongenc.inc' seems to be wrong, try giving an :encoding: option
"""
@@ -44,6 +44,7 @@ HTML_XPATH = {
'images.html': {
".//img[@src='_images/img.png']": '',
".//img[@src='_images/img1.png']": '',
".//img[@src='_images/simg.png']": '',
},
'includes.html': {
".//pre/span[@class='s']": u'üöä',

View File

@@ -54,16 +54,19 @@ def test_images():
htmlbuilder = StandaloneHTMLBuilder(app, env)
htmlbuilder.post_process_images(tree)
assert "no matching candidate for image URI u'foo.*'" in app._warning.content[-1]
assert set(htmlbuilder.images.keys()) == set(['subdir/img.png', 'img.png'])
assert set(htmlbuilder.images.values()) == set(['img.png', 'img1.png'])
assert set(htmlbuilder.images.keys()) == set(['subdir/img.png', 'img.png',
'subdir/simg.png'])
assert set(htmlbuilder.images.values()) == set(['img.png', 'img1.png',
'simg.png'])
app._warning.reset()
latexbuilder = LaTeXBuilder(app, env)
latexbuilder.post_process_images(tree)
assert "no matching candidate for image URI u'foo.*'" in app._warning.content[-1]
assert set(latexbuilder.images.keys()) == set(['subdir/img.png',
assert set(latexbuilder.images.keys()) == set(['subdir/img.png', 'subdir/simg.png',
'img.png', 'img.pdf'])
assert set(latexbuilder.images.values()) == set(['img.pdf', 'img.png', 'img1.png'])
assert set(latexbuilder.images.values()) == set(['img.pdf', 'img.png',
'img1.png', 'simg.pdf'])
def test_second_update():
# delete, add and "edit" (change saved mtime) some files and update again