summaryrefslogtreecommitdiffstats
path: root/tests/test_toctree.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 11:31:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 11:31:33 +0000
commite863fd965dd6253243c3342bd6f0adc4fc8aec4d (patch)
treea4c1b6491a82593950043c3f8b2530e80664d768 /tests/test_toctree.py
parentInitial commit. (diff)
downloadsphinx-upstream.tar.xz
sphinx-upstream.zip
Adding upstream version 5.3.0.upstream/5.3.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/test_toctree.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test_toctree.py b/tests/test_toctree.py
new file mode 100644
index 0000000..39d0916
--- /dev/null
+++ b/tests/test_toctree.py
@@ -0,0 +1,39 @@
+"""Test the HTML builder and check output against XPath."""
+import re
+
+import pytest
+
+
+@pytest.mark.sphinx(testroot='toctree-glob')
+def test_relations(app, status, warning):
+ app.builder.build_all()
+ assert app.builder.relations['index'] == [None, None, 'foo']
+ assert app.builder.relations['foo'] == ['index', 'index', 'bar/index']
+ assert app.builder.relations['bar/index'] == ['index', 'foo', 'bar/bar_1']
+ assert app.builder.relations['bar/bar_1'] == ['bar/index', 'bar/index', 'bar/bar_2']
+ assert app.builder.relations['bar/bar_2'] == ['bar/index', 'bar/bar_1', 'bar/bar_3']
+ assert app.builder.relations['bar/bar_3'] == ['bar/index', 'bar/bar_2', 'bar/bar_4/index']
+ assert app.builder.relations['bar/bar_4/index'] == ['bar/index', 'bar/bar_3', 'baz']
+ assert app.builder.relations['baz'] == ['index', 'bar/bar_4/index', 'qux/index']
+ assert app.builder.relations['qux/index'] == ['index', 'baz', 'qux/qux_1']
+ assert app.builder.relations['qux/qux_1'] == ['qux/index', 'qux/index', 'qux/qux_2']
+ assert app.builder.relations['qux/qux_2'] == ['qux/index', 'qux/qux_1', None]
+ assert 'quux' not in app.builder.relations
+
+
+@pytest.mark.sphinx('singlehtml', testroot='toctree-empty')
+def test_singlehtml_toctree(app, status, warning):
+ app.builder.build_all()
+ try:
+ app.builder._get_local_toctree('index')
+ except AttributeError:
+ pytest.fail('Unexpected AttributeError in app.builder.fix_refuris')
+
+
+@pytest.mark.sphinx(testroot='toctree', srcdir="numbered-toctree")
+def test_numbered_toctree(app, status, warning):
+ # give argument to :numbered: option
+ index = (app.srcdir / 'index.rst').read_text(encoding='utf8')
+ index = re.sub(':numbered:.*', ':numbered: 1', index)
+ (app.srcdir / 'index.rst').write_text(index, encoding='utf8')
+ app.builder.build_all()