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 51 52 53 54 55 56 57 58 59 60
|
"""Test templating."""
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
if TYPE_CHECKING:
from collections.abc import Callable
from sphinx.testing.fixtures import _app_params
from sphinx.testing.util import SphinxTestApp
@pytest.mark.sphinx('html', testroot='templating', copy_test_root=True)
def test_layout_overloading(
make_app: Callable[..., SphinxTestApp], app_params: _app_params
) -> None:
args, kwargs = app_params
app = make_app(*args, **kwargs)
app.build()
result = (app.outdir / 'index.html').read_text(encoding='utf8')
assert '<!-- layout overloading -->' in result
@pytest.mark.sphinx('html', testroot='templating', copy_test_root=True)
def test_autosummary_class_template_overloading(
make_app: Callable[..., SphinxTestApp], app_params: _app_params
) -> None:
args, kwargs = app_params
app = make_app(*args, **kwargs)
app.build()
result = (
app.outdir / 'generated' / 'sphinx.application.TemplateBridge.html'
).read_text(encoding='utf8')
assert 'autosummary/class.rst method block overloading' in result
assert 'foobar' not in result
@pytest.mark.sphinx(
'html',
testroot='templating',
confoverrides={'autosummary_context': {'sentence': 'foobar'}},
copy_test_root=True,
)
def test_autosummary_context(
make_app: Callable[..., SphinxTestApp], app_params: _app_params
) -> None:
args, kwargs = app_params
app = make_app(*args, **kwargs)
app.build()
result = (
app.outdir / 'generated' / 'sphinx.application.TemplateBridge.html'
).read_text(encoding='utf8')
assert 'autosummary/class.rst method block overloading' in result
assert 'foobar' in result
|