mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
test: Update testcase for docutils-0.17 (<figure> and <figcaption>)
Since v0.17, docutils starts to use <figure> and <figcaption> for figure and its caption on HTML output. This modifies the expected value of our testcases to support it.
This commit is contained in:
@@ -13,6 +13,7 @@ import re
|
||||
import pytest
|
||||
|
||||
from sphinx.ext.graphviz import ClickableMapDefinition
|
||||
from sphinx.util import docutils
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-graphviz')
|
||||
@@ -21,9 +22,15 @@ def test_graphviz_png_html(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
html = (r'<div class="figure align-default" .*?>\s*'
|
||||
r'<div class="graphviz"><img .*?/></div>\s*<p class="caption">'
|
||||
r'<span class="caption-text">caption of graph</span>.*</p>\s*</div>')
|
||||
if docutils.__version_info__ < (0, 17):
|
||||
html = (r'<div class="figure align-default" .*?>\s*'
|
||||
r'<div class="graphviz"><img .*?/></div>\s*<p class="caption">'
|
||||
r'<span class="caption-text">caption of graph</span>.*</p>\s*</div>')
|
||||
else:
|
||||
html = (r'<figure class="align-default" .*?>\s*'
|
||||
r'<div class="graphviz"><img .*?/></div>\s*<figcaption>\s*'
|
||||
r'<p><span class="caption-text">caption of graph</span>.*</p>\s*'
|
||||
r'</figcaption>\s*</figure>')
|
||||
assert re.search(html, content, re.S)
|
||||
|
||||
html = 'Hello <div class="graphviz"><img .*?/></div>\n graphviz world'
|
||||
@@ -33,9 +40,15 @@ def test_graphviz_png_html(app, status, warning):
|
||||
'class="graphviz neato-graph" />')
|
||||
assert re.search(html, content, re.S)
|
||||
|
||||
html = (r'<div class="figure align-right" .*?>\s*'
|
||||
r'<div class="graphviz"><img .*?/></div>\s*<p class="caption">'
|
||||
r'<span class="caption-text">on <em>right</em></span>.*</p>\s*</div>')
|
||||
if docutils.__version_info__ < (0, 17):
|
||||
html = (r'<div class="figure align-right" .*?>\s*'
|
||||
r'<div class="graphviz"><img .*?/></div>\s*<p class="caption">'
|
||||
r'<span class="caption-text">on <em>right</em></span>.*</p>\s*</div>')
|
||||
else:
|
||||
html = (r'<figure class="align-right" .*?>\s*'
|
||||
r'<div class="graphviz"><img .*?/></div>\s*<figcaption>\s*'
|
||||
r'<p><span class="caption-text">on <em>right</em></span>.*</p>\s*'
|
||||
r'</figcaption>\s*</figure>')
|
||||
assert re.search(html, content, re.S)
|
||||
|
||||
html = (r'<div align=\"center\" class=\"align-center\">'
|
||||
@@ -53,13 +66,24 @@ def test_graphviz_svg_html(app, status, warning):
|
||||
|
||||
content = (app.outdir / 'index.html').read_text()
|
||||
|
||||
html = (r'<div class=\"figure align-default\" .*?>\n'
|
||||
r'<div class="graphviz"><object data=\".*\.svg\".*>\n'
|
||||
r'\s*<p class=\"warning\">digraph foo {\n'
|
||||
r'bar -> baz\n'
|
||||
r'}</p></object></div>\n'
|
||||
r'<p class=\"caption\"><span class=\"caption-text\">'
|
||||
r'caption of graph</span>.*</p>\n</div>')
|
||||
if docutils.__version_info__ < (0, 17):
|
||||
html = (r'<div class=\"figure align-default\" .*?>\n'
|
||||
r'<div class="graphviz"><object data=\".*\.svg\".*>\n'
|
||||
r'\s*<p class=\"warning\">digraph foo {\n'
|
||||
r'bar -> baz\n'
|
||||
r'}</p></object></div>\n'
|
||||
r'<p class=\"caption\"><span class=\"caption-text\">'
|
||||
r'caption of graph</span>.*</p>\n</div>')
|
||||
else:
|
||||
html = (r'<figure class=\"align-default\" .*?>\n'
|
||||
r'<div class="graphviz"><object data=\".*\.svg\".*>\n'
|
||||
r'\s*<p class=\"warning\">digraph foo {\n'
|
||||
r'bar -> baz\n'
|
||||
r'}</p></object></div>\n'
|
||||
r'<figcaption>\n'
|
||||
r'<p><span class=\"caption-text\">caption of graph</span>.*</p>\n'
|
||||
r'</figcaption>\n'
|
||||
r'</figure>')
|
||||
assert re.search(html, content, re.S)
|
||||
|
||||
html = (r'Hello <div class="graphviz"><object.*>\n'
|
||||
@@ -67,14 +91,25 @@ def test_graphviz_svg_html(app, status, warning):
|
||||
r' graphviz world')
|
||||
assert re.search(html, content, re.S)
|
||||
|
||||
html = (r'<div class=\"figure align-right\" .*\>\n'
|
||||
r'<div class="graphviz"><object data=\".*\.svg\".*>\n'
|
||||
r'\s*<p class=\"warning\">digraph bar {\n'
|
||||
r'foo -> bar\n'
|
||||
r'}</p></object></div>\n'
|
||||
r'<p class=\"caption\"><span class=\"caption-text\">'
|
||||
r'on <em>right</em></span>.*</p>\n'
|
||||
r'</div>')
|
||||
if docutils.__version_info__ < (0, 17):
|
||||
html = (r'<div class=\"figure align-right\" .*\>\n'
|
||||
r'<div class="graphviz"><object data=\".*\.svg\".*>\n'
|
||||
r'\s*<p class=\"warning\">digraph bar {\n'
|
||||
r'foo -> bar\n'
|
||||
r'}</p></object></div>\n'
|
||||
r'<p class=\"caption\"><span class=\"caption-text\">'
|
||||
r'on <em>right</em></span>.*</p>\n'
|
||||
r'</div>')
|
||||
else:
|
||||
html = (r'<figure class=\"align-right\" .*\>\n'
|
||||
r'<div class="graphviz"><object data=\".*\.svg\".*>\n'
|
||||
r'\s*<p class=\"warning\">digraph bar {\n'
|
||||
r'foo -> bar\n'
|
||||
r'}</p></object></div>\n'
|
||||
r'<figcaption>\n'
|
||||
r'<p><span class=\"caption-text\">on <em>right</em></span>.*</p>\n'
|
||||
r'</figcaption>\n'
|
||||
r'</figure>')
|
||||
assert re.search(html, content, re.S)
|
||||
|
||||
html = (r'<div align=\"center\" class=\"align-center\">'
|
||||
|
||||
Reference in New Issue
Block a user