Debian Codegraph @

tests/test_directives/test_directive_option.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(
12 'html',
13 testroot='root',
14 confoverrides={'option_emphasise_placeholders': True},
15 )
16 def test_option_emphasise_placeholders(app: SphinxTestApp) -> None:
17 app.build()
18 content = (app.outdir / 'objects.html').read_text(encoding='utf8')
19 assert '<em><span class="pre">TYPE</span></em>' in content
20 assert '{TYPE}' not in content
21 assert (
22 '<em><span class="pre">WHERE</span></em>'
23 '<span class="pre">-</span>'
24 '<em><span class="pre">COUNT</span></em>'
25 ) in content
26 assert '<span class="pre">{{value}}</span>' in content
27 assert (
28 '<span class="pre">--plugin.option</span></span>'
29 '<a class="headerlink" href="#cmdoption-perl-plugin.option" title="Link to this definition">¶</a></dt>'
30 ) in content
31
32
33 @pytest.mark.sphinx('html', testroot='root')
34 def test_option_emphasise_placeholders_default(app: SphinxTestApp) -> None:
35 app.build()
36 content = (app.outdir / 'objects.html').read_text(encoding='utf8')
37 assert '<span class="pre">={TYPE}</span>' in content
38 assert '<span class="pre">={WHERE}-{COUNT}</span></span>' in content
39 assert '<span class="pre">{client_name}</span>' in content
40 assert (
41 '<span class="pre">--plugin.option</span></span>'
42 '<span class="sig-prename descclassname"></span>'
43 '<a class="headerlink" href="#cmdoption-perl-plugin.option" title="Link to this definition">¶</a></dt>'
44 ) in content
45
46
47 @pytest.mark.sphinx('html', testroot='root')
48 def test_option_reference_with_value(app: SphinxTestApp) -> None:
49 app.build()
50 content = (app.outdir / 'objects.html').read_text(encoding='utf-8')
51 assert (
52 '<span class="pre">-mapi</span></span><span class="sig-prename descclassname">'
53 '</span><a class="headerlink" href="#cmdoption-git-commit-mapi"'
54 ) in content
55 assert (
56 'first option <a class="reference internal" href="#cmdoption-git-commit-mapi">'
57 ) in content
58 assert (
59 '<a class="reference internal" href="#cmdoption-git-commit-mapi">'
60 '<code class="xref std std-option docutils literal notranslate"><span class="pre">-mapi[=xxx]</span></code></a>'
61 ) in content
62 assert (
63 '<span class="pre">-mapi</span> <span class="pre">with_space</span>'
64 ) in content