File: test_html_theme.py

package info (click to toggle)
sphinx 8.2.3-12
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid
  • size: 26,960 kB
  • sloc: python: 105,864; javascript: 6,474; perl: 449; makefile: 178; sh: 37; xml: 19; ansic: 2
file content (50 lines) | stat: -rw-r--r-- 1,447 bytes parent folder | download | duplicates (10)
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
41
42
43
44
45
46
47
48
49
50
from __future__ import annotations

from typing import TYPE_CHECKING

import pytest

if TYPE_CHECKING:
    from sphinx.testing.util import SphinxTestApp


@pytest.mark.sphinx('html', testroot='theming')
def test_theme_options(app: SphinxTestApp) -> None:
    app.build()

    result = (app.outdir / '_static' / 'documentation_options.js').read_text(
        encoding='utf8'
    )
    assert 'NAVIGATION_WITH_KEYS: false' in result
    assert 'ENABLE_SEARCH_SHORTCUTS: true' in result


@pytest.mark.sphinx(
    'html',
    testroot='theming',
    confoverrides={
        'html_theme_options.navigation_with_keys': True,
        'html_theme_options.enable_search_shortcuts': False,
    },
)
def test_theme_options_with_override(app: SphinxTestApp) -> None:
    app.build()

    result = (app.outdir / '_static' / 'documentation_options.js').read_text(
        encoding='utf8'
    )
    assert 'NAVIGATION_WITH_KEYS: true' in result
    assert 'ENABLE_SEARCH_SHORTCUTS: false' in result


@pytest.mark.sphinx('html', testroot='build-html-theme-having-multiple-stylesheets')
def test_theme_having_multiple_stylesheets(app: SphinxTestApp) -> None:
    app.build()
    content = (app.outdir / 'index.html').read_text(encoding='utf-8')

    assert (
        '<link rel="stylesheet" type="text/css" href="_static/mytheme.css" />'
    ) in content
    assert (
        '<link rel="stylesheet" type="text/css" href="_static/extra.css" />'
    ) in content