Debian Codegraph @

tests/test_writers/test_docutilsconf.py

raw
1 """Test docutils.conf support for several writers."""
2
3 from __future__ import annotations
4
5 from typing import TYPE_CHECKING
6
7 import pytest
8 from docutils import nodes
9
10 from sphinx.testing.util import assert_node
11 from sphinx.util.docutils import patch_docutils
12
13 if TYPE_CHECKING:
14 from sphinx.application import Sphinx
15
16
17 @pytest.mark.sphinx(
18 'dummy',
19 testroot='docutilsconf',
20 freshenv=True,
21 )
22 def test_html_with_default_docutilsconf(app: Sphinx) -> None:
23 with patch_docutils(app.confdir):
24 app.build()
25
26 doctree = app.env.get_doctree('index')
27 section = doctree[0]
28 assert isinstance(section, nodes.Element)
29 assert_node(
30 section[1], [nodes.paragraph, ('Sphinx ', [nodes.footnote_reference, '1'])]
31 )
32
33
34 @pytest.mark.sphinx(
35 'dummy',
36 testroot='docutilsconf',
37 freshenv=True,
38 docutils_conf='[restructuredtext parser]\ntrim_footnote_reference_space: true\n',
39 copy_test_root=True,
40 )
41 def test_html_with_docutilsconf(app: Sphinx) -> None:
42 with patch_docutils(app.confdir):
43 app.build()
44
45 doctree = app.env.get_doctree('index')
46 section = doctree[0]
47 assert isinstance(section, nodes.Element)
48 assert_node(
49 section[1], [nodes.paragraph, ('Sphinx', [nodes.footnote_reference, '1'])]
50 )