From 447582724de08fafb1f954a3c50c953382352d49 Mon Sep 17 00:00:00 2001
From: Oliver Sanders
Date: Mon, 18 Sep 2017 11:10:19 +0100
Subject: [PATCH] Add test for ext.graphviz alignment.
---
tests/roots/test-ext-graphviz/index.rst | 5 +++
tests/test_ext_graphviz.py | 52 ++++++++++++++++++++++++-
2 files changed, 56 insertions(+), 1 deletion(-)
diff --git a/tests/roots/test-ext-graphviz/index.rst b/tests/roots/test-ext-graphviz/index.rst
index ab86e2a5a..930ec656d 100644
--- a/tests/roots/test-ext-graphviz/index.rst
+++ b/tests/roots/test-ext-graphviz/index.rst
@@ -25,3 +25,8 @@ Hello |graph| graphviz world
:caption: on right
foo -> bar
+
+.. digraph:: foo
+ :align: center
+
+ centered
diff --git a/tests/test_ext_graphviz.py b/tests/test_ext_graphviz.py
index 6affda7ab..1d2a3ab2f 100644
--- a/tests/test_ext_graphviz.py
+++ b/tests/test_ext_graphviz.py
@@ -16,7 +16,7 @@ import pytest
@pytest.mark.sphinx('html', testroot='ext-graphviz')
@pytest.mark.usefixtures('if_graphviz_found')
-def test_graphviz_html(app, status, warning):
+def test_graphviz_png_html(app, status, warning):
app.builder.build_all()
content = (app.outdir / 'index.html').text()
@@ -34,6 +34,51 @@ def test_graphviz_html(app, status, warning):
r'on right.*
\s*')
assert re.search(html, content, re.S)
+ html = (r''
+ r'

\n
')
+ assert re.search(html, content, re.S)
+
+@pytest.mark.sphinx('html', testroot='ext-graphviz',
+ confoverrides={'graphviz_output_format': 'svg'})
+@pytest.mark.usefixtures('if_graphviz_found')
+def test_graphviz_svg_html(app, status, warning):
+ app.builder.build_all()
+
+ content = (app.outdir / 'index.html').text()
+
+ html = (r'')
+ assert re.search(html, content, re.S)
+
+ html = (r'Hello \n'
+ r'\s+graph
\n'
+ r' graphviz world')
+ assert re.search(html, content, re.S)
+
+ html = (r'')
+ assert re.search(html, content, re.S)
+
+ html = (r''
+ r'
\n'
+ r'
')
+ assert re.search(html, content, re.S)
@pytest.mark.sphinx('latex', testroot='ext-graphviz')
@pytest.mark.usefixtures('if_graphviz_found')
@@ -54,6 +99,11 @@ def test_graphviz_latex(app, status, warning):
'\\\\caption{on right}\\\\label{.*}\\\\end{wrapfigure}')
assert re.search(macro, content, re.S)
+ macro = (r'\{\\hfill'
+ r'\\includegraphics{graphviz-.*}'
+ r'\\hspace\*{\\fill}}')
+ assert re.search(macro, content, re.S)
+
@pytest.mark.sphinx('html', testroot='ext-graphviz', confoverrides={'language': 'xx'})
@pytest.mark.usefixtures('if_graphviz_found')