2022-02-19 21:05:56 -06:00
|
|
|
"""Test dirhtml builder."""
|
2020-02-06 08:19:03 -06:00
|
|
|
|
|
|
|
import posixpath
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
from sphinx.util.inventory import InventoryFile
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx(buildername='dirhtml', testroot='builder-dirhtml')
|
|
|
|
def test_dirhtml(app, status, warning):
|
|
|
|
app.build()
|
|
|
|
|
|
|
|
assert (app.outdir / 'index.html').exists()
|
|
|
|
assert (app.outdir / 'foo/index.html').exists()
|
|
|
|
assert (app.outdir / 'foo/foo_1/index.html').exists()
|
|
|
|
assert (app.outdir / 'foo/foo_2/index.html').exists()
|
|
|
|
assert (app.outdir / 'bar/index.html').exists()
|
|
|
|
|
2022-04-26 21:04:19 -05:00
|
|
|
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
2020-02-06 08:19:03 -06:00
|
|
|
assert 'href="foo/"' in content
|
|
|
|
assert 'href="foo/foo_1/"' in content
|
|
|
|
assert 'href="foo/foo_2/"' in content
|
|
|
|
assert 'href="bar/"' in content
|
|
|
|
|
|
|
|
# objects.inv (refs: #7095)
|
2020-02-16 05:44:38 -06:00
|
|
|
with (app.outdir / 'objects.inv').open('rb') as f:
|
|
|
|
invdata = InventoryFile.load(f, 'path/to', posixpath.join)
|
|
|
|
|
2020-02-06 08:19:03 -06:00
|
|
|
assert 'index' in invdata.get('std:doc')
|
2023-01-31 12:30:43 -06:00
|
|
|
assert invdata['std:doc']['index'] == ('Python', '', 'path/to/', '-')
|
2020-02-06 08:19:03 -06:00
|
|
|
|
|
|
|
assert 'foo/index' in invdata.get('std:doc')
|
2023-01-31 12:30:43 -06:00
|
|
|
assert invdata['std:doc']['foo/index'] == ('Python', '', 'path/to/foo/', '-')
|
2020-02-06 08:19:03 -06:00
|
|
|
|
|
|
|
assert 'index' in invdata.get('std:label')
|
2023-01-31 12:30:43 -06:00
|
|
|
assert invdata['std:label']['index'] == ('Python', '', 'path/to/#index', '-')
|
2020-02-06 08:19:03 -06:00
|
|
|
|
|
|
|
assert 'foo' in invdata.get('std:label')
|
2023-01-31 12:30:43 -06:00
|
|
|
assert invdata['std:label']['foo'] == ('Python', '', 'path/to/foo/#foo', 'foo/index')
|