summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIgnacio Fdez. Galván <Ignacio.Fernandez@kemi.uu.se>2015-03-17 15:57:51 +0100
committerIgnacio Fdez. Galván <Ignacio.Fernandez@kemi.uu.se>2015-03-17 15:57:51 +0100
commitd86efb91927dfd75cd3d02039a3fe9ede2644ffa (patch)
tree6bff691201a20839e4c1f524f650b6a3a7d9ec00 /tests
parent6b76e25ce905cc222b8a7ffe7e31aa39d44818e7 (diff)
downloadsphinx-git-d86efb91927dfd75cd3d02039a3fe9ede2644ffa.tar.gz
Test for alternate stylesheets
Diffstat (limited to 'tests')
-rw-r--r--tests/roots/test-stylesheets/_templates/layout.html7
-rw-r--r--tests/roots/test-stylesheets/conf.py12
-rw-r--r--tests/roots/test-stylesheets/index.rst4
-rw-r--r--tests/test_build_html.py43
4 files changed, 66 insertions, 0 deletions
diff --git a/tests/roots/test-stylesheets/_templates/layout.html b/tests/roots/test-stylesheets/_templates/layout.html
new file mode 100644
index 000000000..3e561619b
--- /dev/null
+++ b/tests/roots/test-stylesheets/_templates/layout.html
@@ -0,0 +1,7 @@
+{% extends "!layout.html" %}
+{% set css_files = css_files + ["_static/more_persistent.css",
+ {"filename": "_static/more_persistent2.css"},
+ {"filename": "_static/more_default.css", "title": "Default", "alternate": False},
+ {"filename": "_static/more_alternate1.css", "title": "Alternate"},
+ {"filename": "_static/more_alternate2.css", "alternate": True}] %}
+
diff --git a/tests/roots/test-stylesheets/conf.py b/tests/roots/test-stylesheets/conf.py
new file mode 100644
index 000000000..8e072de59
--- /dev/null
+++ b/tests/roots/test-stylesheets/conf.py
@@ -0,0 +1,12 @@
+# -*- coding: utf-8 -*-
+
+master_doc = 'index'
+html_theme = 'classic'
+templates_path = ['_templates']
+
+def setup(app):
+ app.add_stylesheet('persistent.css')
+ app.add_stylesheet('default.css', title="Default", alternate=False)
+ app.add_stylesheet('alternate1.css', title="Alternate")
+ app.add_stylesheet('alternate2.css', alternate=True)
+
diff --git a/tests/roots/test-stylesheets/index.rst b/tests/roots/test-stylesheets/index.rst
new file mode 100644
index 000000000..c5c5766ba
--- /dev/null
+++ b/tests/roots/test-stylesheets/index.rst
@@ -0,0 +1,4 @@
+test-stylesheets
+================
+
+Lorem ipsum dolor
diff --git a/tests/test_build_html.py b/tests/test_build_html.py
index 3ee89b72b..adefa5c11 100644
--- a/tests/test_build_html.py
+++ b/tests/test_build_html.py
@@ -919,3 +919,46 @@ def test_numfig_with_secnum_depth(app, status, warning):
for xpath, check, be_found in paths:
yield check_xpath, etree, fname, xpath, check, be_found
+
+@gen_with_app(buildername='html', testroot='stylesheets')
+def test_alternate_stylesheets(app, status, warning):
+ app.builder.build_all()
+
+ expects = {
+ 'index.html': [
+ (".//link[@href='_static/persistent.css']"
+ "[@rel='stylesheet']", '', True),
+ (".//link[@href='_static/default.css']"
+ "[@rel='stylesheet']"
+ "[@title='Default']", '', True),
+ (".//link[@href='_static/alternate1.css']"
+ "[@rel='alternate stylesheet']"
+ "[@title='Alternate']", '', True),
+ (".//link[@href='_static/alternate2.css']"
+ "[@rel='alternate stylesheet']", '', True),
+ (".//link[@href='_static/more_persistent.css']"
+ "[@rel='stylesheet']", '', True),
+ (".//link[@href='_static/more_persistent2.css']"
+ "[@rel='stylesheet']", '', True),
+ (".//link[@href='_static/more_default.css']"
+ "[@rel='stylesheet']"
+ "[@title='Default']", '', True),
+ (".//link[@href='_static/more_alternate1.css']"
+ "[@rel='alternate stylesheet']"
+ "[@title='Alternate']", '', True),
+ (".//link[@href='_static/more_alternate2.css']"
+ "[@rel='alternate stylesheet']", '', True),
+ ],
+ }
+
+ for fname, paths in iteritems(expects):
+ parser = NslessParser()
+ parser.entity.update(html_entities.entitydefs)
+ fp = open(os.path.join(app.outdir, fname), 'rb')
+ try:
+ etree = ET.parse(fp, parser)
+ finally:
+ fp.close()
+
+ for xpath, check, be_found in paths:
+ yield check_xpath, etree, fname, xpath, check, be_found