diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-03-18 12:32:23 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-03-18 12:33:00 +0900 |
commit | dc3faa57b47c0c0e1ded6740d9a8912d26ded76c (patch) | |
tree | 64c2742e8128faa44bcacf366362bc931e832a60 | |
parent | dfd550eca6c1fe66d9801f90be509fc869c4b8a5 (diff) | |
download | sphinx-git-dc3faa57b47c0c0e1ded6740d9a8912d26ded76c.tar.gz |
Add testcase for qthelp (.qhp files)
-rw-r--r-- | tests/test_build_qthelp.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/test_build_qthelp.py b/tests/test_build_qthelp.py index 541e03b75..3beddf554 100644 --- a/tests/test_build_qthelp.py +++ b/tests/test_build_qthelp.py @@ -13,11 +13,23 @@ import pytest +from sphinx.testing.util import etree_parse + @pytest.mark.sphinx('qthelp', testroot='basic') def test_qthelp_basic(app, status, warning): app.builder.build_all() + qhp = (app.outdir / 'Python.qhp').text() + assert '<customFilter name="Python ">' in qhp + assert '<filterAttribute>Python</filterAttribute>' in qhp + assert '<filterAttribute></filterAttribute>' in qhp + assert '<section title="Python documentation" ref="index.html">' in qhp + assert '<file>genindex.html</file>' in qhp + assert '<file>index.html</file>' in qhp + assert '<file>_static/basic.css</file>' in qhp + assert '<file>_static/down.png</file>' in qhp + qhcp = (app.outdir / 'Python.qhcp').text() assert '<title>Python documentation</title>' in qhcp assert '<homePage>qthelp://org.sphinx.python/doc/index.html</homePage>' in qhcp @@ -27,6 +39,27 @@ def test_qthelp_basic(app, status, warning): assert '<file>Python.qch</file>' in qhcp +@pytest.mark.sphinx('qthelp', testroot='toctree') +def test_qthelp_toctree(app, status, warning): + app.builder.build_all() + + et = etree_parse(app.outdir / 'Python.qhp') + toc = et.find('.//toc') + assert len(toc) == 1 + assert toc[0].attrib == {'title': 'Python documentation', + 'ref': 'index.html'} + assert len(toc[0]) == 4 + assert toc[0][0].attrib == {'title': 'foo', 'ref': 'foo.html'} + assert toc[0][1].attrib == {'title': 'bar', 'ref': 'bar.html'} + assert toc[0][0][0].attrib == {'title': 'quux', 'ref': 'quux.html'} + assert toc[0][0][1].attrib == {'title': 'foo.1', 'ref': 'foo.html#foo-1'} + assert toc[0][0][1][0].attrib == {'title': 'foo.1-1', 'ref': 'foo.html#foo-1-1'} + assert toc[0][0][2].attrib == {'title': 'foo.2', 'ref': 'foo.html#foo-2'} + assert toc[0][2].attrib == {'title': 'http://sphinx-doc.org/', + 'ref': 'http://sphinx-doc.org/'} + assert toc[0][3].attrib == {'title': 'baz', 'ref': 'baz.html'} + + @pytest.mark.sphinx('qthelp', testroot='basic') def test_qthelp_namespace(app, status, warning): # default namespace |