1"""
2    test_templating
3    ~~~~~~~~~~~~~~~~
4
5    Test templating.
6
7    :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
8    :license: BSD, see LICENSE for details.
9"""
10
11import pytest
12
13from sphinx.ext.autosummary.generate import setup_documenters
14
15
16@pytest.mark.sphinx('html', testroot='templating')
17def test_layout_overloading(make_app, app_params):
18    args, kwargs = app_params
19    app = make_app(*args, **kwargs)
20    setup_documenters(app)
21    app.builder.build_update()
22
23    result = (app.outdir / 'index.html').read_text()
24    assert '<!-- layout overloading -->' in result
25
26
27@pytest.mark.sphinx('html', testroot='templating')
28def test_autosummary_class_template_overloading(make_app, app_params):
29    args, kwargs = app_params
30    app = make_app(*args, **kwargs)
31    setup_documenters(app)
32    app.builder.build_update()
33
34    result = (app.outdir / 'generated' / 'sphinx.application.TemplateBridge.html').read_text()
35    assert 'autosummary/class.rst method block overloading' in result
36    assert 'foobar' not in result
37
38
39@pytest.mark.sphinx('html', testroot='templating',
40                    confoverrides={'autosummary_context': {'sentence': 'foobar'}})
41def test_autosummary_context(make_app, app_params):
42    args, kwargs = app_params
43    app = make_app(*args, **kwargs)
44    setup_documenters(app)
45    app.builder.build_update()
46
47    result = (app.outdir / 'generated' / 'sphinx.application.TemplateBridge.html').read_text()
48    assert 'autosummary/class.rst method block overloading' in result
49    assert 'foobar' in result
50