summaryrefslogtreecommitdiff
path: root/tests/test_ext_graphviz.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_ext_graphviz.py')
-rw-r--r--tests/test_ext_graphviz.py77
1 files changed, 56 insertions, 21 deletions
diff --git a/tests/test_ext_graphviz.py b/tests/test_ext_graphviz.py
index a19261e96..1671133e7 100644
--- a/tests/test_ext_graphviz.py
+++ b/tests/test_ext_graphviz.py
@@ -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 -&gt; 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 -&gt; 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 -&gt; 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 -&gt; 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 -&gt; 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 -&gt; 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\">'