2022-02-19 21:05:56 -06:00
|
|
|
"""Test the HTML builder and check output against XPath."""
|
2018-06-06 10:54:02 -05:00
|
|
|
import re
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
import pytest
|
2015-12-26 06:43:54 -06:00
|
|
|
|
2017-01-25 10:13:17 -06:00
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx(testroot='toctree-glob')
|
2015-12-26 06:43:54 -06:00
|
|
|
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']
|
2015-12-26 08:57:09 -06:00
|
|
|
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
|
2017-03-05 15:16:37 -06:00
|
|
|
|
|
|
|
|
|
|
|
@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')
|
2018-06-06 10:54:02 -05:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx(testroot='toctree', srcdir="numbered-toctree")
|
|
|
|
def test_numbered_toctree(app, status, warning):
|
|
|
|
# give argument to :numbered: option
|
2020-01-31 20:58:51 -06:00
|
|
|
index = (app.srcdir / 'index.rst').read_text()
|
2018-06-06 10:54:02 -05:00
|
|
|
index = re.sub(':numbered:.*', ':numbered: 1', index)
|
2019-01-02 07:39:06 -06:00
|
|
|
(app.srcdir / 'index.rst').write_text(index)
|
2018-06-06 10:54:02 -05:00
|
|
|
app.builder.build_all()
|