1313import pytest
1414
1515from sphinx .ext .graphviz import ClickableMapDefinition
16+ from sphinx .util import docutils
1617
1718
1819@pytest .mark .sphinx ('html' , testroot = 'ext-graphviz' )
@@ -21,9 +22,15 @@ def test_graphviz_png_html(app, status, warning):
2122 app .builder .build_all ()
2223
2324 content = (app .outdir / 'index.html' ).read_text ()
24- html = (r'<div class="figure align-default" .*?>\s*'
25- r'<div class="graphviz"><img .*?/></div>\s*<p class="caption">'
26- r'<span class="caption-text">caption of graph</span>.*</p>\s*</div>' )
25+ if docutils .__version_info__ < (0 , 17 ):
26+ html = (r'<div class="figure align-default" .*?>\s*'
27+ r'<div class="graphviz"><img .*?/></div>\s*<p class="caption">'
28+ r'<span class="caption-text">caption of graph</span>.*</p>\s*</div>' )
29+ else :
30+ html = (r'<figure class="align-default" .*?>\s*'
31+ r'<div class="graphviz"><img .*?/></div>\s*<figcaption>\s*'
32+ r'<p><span class="caption-text">caption of graph</span>.*</p>\s*'
33+ r'</figcaption>\s*</figure>' )
2734 assert re .search (html , content , re .S )
2835
2936 html = 'Hello <div class="graphviz"><img .*?/></div>\n graphviz world'
@@ -33,9 +40,15 @@ def test_graphviz_png_html(app, status, warning):
3340 'class="graphviz neato-graph" />' )
3441 assert re .search (html , content , re .S )
3542
36- html = (r'<div class="figure align-right" .*?>\s*'
37- r'<div class="graphviz"><img .*?/></div>\s*<p class="caption">'
38- r'<span class="caption-text">on <em>right</em></span>.*</p>\s*</div>' )
43+ if docutils .__version_info__ < (0 , 17 ):
44+ html = (r'<div class="figure align-right" .*?>\s*'
45+ r'<div class="graphviz"><img .*?/></div>\s*<p class="caption">'
46+ r'<span class="caption-text">on <em>right</em></span>.*</p>\s*</div>' )
47+ else :
48+ html = (r'<figure class="align-right" .*?>\s*'
49+ r'<div class="graphviz"><img .*?/></div>\s*<figcaption>\s*'
50+ r'<p><span class="caption-text">on <em>right</em></span>.*</p>\s*'
51+ r'</figcaption>\s*</figure>' )
3952 assert re .search (html , content , re .S )
4053
4154 html = (r'<div align=\"center\" class=\"align-center\">'
@@ -53,28 +66,50 @@ def test_graphviz_svg_html(app, status, warning):
5366
5467 content = (app .outdir / 'index.html' ).read_text ()
5568
56- html = (r'<div class=\"figure align-default\" .*?>\n'
57- r'<div class="graphviz"><object data=\".*\.svg\".*>\n'
58- r'\s*<p class=\"warning\">digraph foo {\n'
59- r'bar -> baz\n'
60- r'}</p></object></div>\n'
61- r'<p class=\"caption\"><span class=\"caption-text\">'
62- r'caption of graph</span>.*</p>\n</div>' )
69+ if docutils .__version_info__ < (0 , 17 ):
70+ html = (r'<div class=\"figure align-default\" .*?>\n'
71+ r'<div class="graphviz"><object data=\".*\.svg\".*>\n'
72+ r'\s*<p class=\"warning\">digraph foo {\n'
73+ r'bar -> baz\n'
74+ r'}</p></object></div>\n'
75+ r'<p class=\"caption\"><span class=\"caption-text\">'
76+ r'caption of graph</span>.*</p>\n</div>' )
77+ else :
78+ html = (r'<figure class=\"align-default\" .*?>\n'
79+ r'<div class="graphviz"><object data=\".*\.svg\".*>\n'
80+ r'\s*<p class=\"warning\">digraph foo {\n'
81+ r'bar -> baz\n'
82+ r'}</p></object></div>\n'
83+ r'<figcaption>\n'
84+ r'<p><span class=\"caption-text\">caption of graph</span>.*</p>\n'
85+ r'</figcaption>\n'
86+ r'</figure>' )
6387 assert re .search (html , content , re .S )
6488
6589 html = (r'Hello <div class="graphviz"><object.*>\n'
6690 r'\s*<p class=\"warning\">graph</p></object></div>\n'
6791 r' graphviz world' )
6892 assert re .search (html , content , re .S )
6993
70- html = (r'<div class=\"figure align-right\" .*\>\n'
71- r'<div class="graphviz"><object data=\".*\.svg\".*>\n'
72- r'\s*<p class=\"warning\">digraph bar {\n'
73- r'foo -> bar\n'
74- r'}</p></object></div>\n'
75- r'<p class=\"caption\"><span class=\"caption-text\">'
76- r'on <em>right</em></span>.*</p>\n'
77- r'</div>' )
94+ if docutils .__version_info__ < (0 , 17 ):
95+ html = (r'<div class=\"figure align-right\" .*\>\n'
96+ r'<div class="graphviz"><object data=\".*\.svg\".*>\n'
97+ r'\s*<p class=\"warning\">digraph bar {\n'
98+ r'foo -> bar\n'
99+ r'}</p></object></div>\n'
100+ r'<p class=\"caption\"><span class=\"caption-text\">'
101+ r'on <em>right</em></span>.*</p>\n'
102+ r'</div>' )
103+ else :
104+ html = (r'<figure class=\"align-right\" .*\>\n'
105+ r'<div class="graphviz"><object data=\".*\.svg\".*>\n'
106+ r'\s*<p class=\"warning\">digraph bar {\n'
107+ r'foo -> bar\n'
108+ r'}</p></object></div>\n'
109+ r'<figcaption>\n'
110+ r'<p><span class=\"caption-text\">on <em>right</em></span>.*</p>\n'
111+ r'</figcaption>\n'
112+ r'</figure>' )
78113 assert re .search (html , content , re .S )
79114
80115 html = (r'<div align=\"center\" class=\"align-center\">'
0 commit comments