File: test_build_dirhtml.py

package info (click to toggle)
sphinx 4.5.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 22,656 kB
  • sloc: python: 74,641; javascript: 14,242; perl: 420; makefile: 247; sh: 57; xml: 19; ansic: 1
file content (40 lines) | stat: -rw-r--r-- 1,392 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""Test dirhtml builder."""

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()

    content = (app.outdir / 'index.html').read_text()
    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)
    with (app.outdir / 'objects.inv').open('rb') as f:
        invdata = InventoryFile.load(f, 'path/to', posixpath.join)

    assert 'index' in invdata.get('std:doc')
    assert ('Python', '', 'path/to/', '-') == invdata['std:doc']['index']

    assert 'foo/index' in invdata.get('std:doc')
    assert ('Python', '', 'path/to/foo/', '-') == invdata['std:doc']['foo/index']

    assert 'index' in invdata.get('std:label')
    assert ('Python', '', 'path/to/#index', '-') == invdata['std:label']['index']

    assert 'foo' in invdata.get('std:label')
    assert ('Python', '', 'path/to/foo/#foo', 'foo/index') == invdata['std:label']['foo']