From dc3faa57b47c0c0e1ded6740d9a8912d26ded76c Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 18 Mar 2018 12:32:23 +0900 Subject: [PATCH] Add testcase for qthelp (.qhp files) --- tests/test_build_qthelp.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) 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 '' in qhp + assert 'Python' in qhp + assert '' in qhp + assert '
' in qhp + assert 'genindex.html' in qhp + assert 'index.html' in qhp + assert '_static/basic.css' in qhp + assert '_static/down.png' in qhp + qhcp = (app.outdir / 'Python.qhcp').text() assert 'Python documentation' in qhcp assert 'qthelp://org.sphinx.python/doc/index.html' in qhcp @@ -27,6 +39,27 @@ def test_qthelp_basic(app, status, warning): assert 'Python.qch' 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