Debian Codegraph @

tests/test_theming/test_html_theme.py

raw
1 from __future__ import annotations
2
3 from typing import TYPE_CHECKING
4
5 import pytest
6
7 if TYPE_CHECKING:
8 from sphinx.testing.util import SphinxTestApp
9
10
11 @pytest.mark.sphinx('html', testroot='theming')
12 def test_theme_options(app: SphinxTestApp) -> None:
13 app.build()
14
15 result = (app.outdir / '_static' / 'documentation_options.js').read_text(
16 encoding='utf8'
17 )
18 assert 'NAVIGATION_WITH_KEYS: false' in result
19 assert 'ENABLE_SEARCH_SHORTCUTS: true' in result
20
21
22 @pytest.mark.sphinx(
23 'html',
24 testroot='theming',
25 confoverrides={
26 'html_theme_options.navigation_with_keys': True,
27 'html_theme_options.enable_search_shortcuts': False,
28 },
29 )
30 def test_theme_options_with_override(app: SphinxTestApp) -> None:
31 app.build()
32
33 result = (app.outdir / '_static' / 'documentation_options.js').read_text(
34 encoding='utf8'
35 )
36 assert 'NAVIGATION_WITH_KEYS: true' in result
37 assert 'ENABLE_SEARCH_SHORTCUTS: false' in result
38
39
40 @pytest.mark.sphinx('html', testroot='build-html-theme-having-multiple-stylesheets')
41 def test_theme_having_multiple_stylesheets(app: SphinxTestApp) -> None:
42 app.build()
43 content = (app.outdir / 'index.html').read_text(encoding='utf-8')
44
45 assert (
46 '<link rel="stylesheet" type="text/css" href="_static/mytheme.css" />'
47 ) in content
48 assert (
49 '<link rel="stylesheet" type="text/css" href="_static/extra.css" />'
50 ) in content