summaryrefslogtreecommitdiffstats
path: root/tests/test_directives_no_typesetting.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-05 16:20:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-05 16:20:58 +0000
commit5bb0bb4be543fd5eca41673696a62ed80d493591 (patch)
treead2c464f140e86c7f178a6276d7ea4a93e3e6c92 /tests/test_directives_no_typesetting.py
parentAdding upstream version 7.2.6. (diff)
downloadsphinx-upstream.tar.xz
sphinx-upstream.zip
Adding upstream version 7.3.7.upstream/7.3.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_directives_no_typesetting.py')
-rw-r--r--tests/test_directives_no_typesetting.py108
1 files changed, 0 insertions, 108 deletions
diff --git a/tests/test_directives_no_typesetting.py b/tests/test_directives_no_typesetting.py
deleted file mode 100644
index fd101fb..0000000
--- a/tests/test_directives_no_typesetting.py
+++ /dev/null
@@ -1,108 +0,0 @@
-"""Tests the directives"""
-
-import pytest
-from docutils import nodes
-
-from sphinx import addnodes
-from sphinx.testing import restructuredtext
-from sphinx.testing.util import assert_node
-
-DOMAINS = [
- # directive, no-index, no-index-entry, signature of f, signature of g, index entry of g
- ('c:function', False, True, 'void f()', 'void g()', ('single', 'g (C function)', 'c.g', '', None)),
- ('cpp:function', False, True, 'void f()', 'void g()', ('single', 'g (C++ function)', '_CPPv41gv', '', None)),
- ('js:function', True, True, 'f()', 'g()', ('single', 'g() (built-in function)', 'g', '', None)),
- ('py:function', True, True, 'f()', 'g()', ('pair', 'built-in function; g()', 'g', '', None)),
- ('rst:directive', True, False, 'f', 'g', ('single', 'g (directive)', 'directive-g', '', None)),
- ('cmdoption', True, False, 'f', 'g', ('pair', 'command line option; g', 'cmdoption-arg-g', '', None)),
- ('envvar', True, False, 'f', 'g', ('single', 'environment variable; g', 'envvar-g', '', None)),
-]
-
-
-@pytest.mark.parametrize(('directive', 'no_index', 'no_index_entry', 'sig_f', 'sig_g', 'index_g'), DOMAINS)
-def test_object_description_no_typesetting(app, directive, no_index, no_index_entry, sig_f, sig_g, index_g):
- text = (f'.. {directive}:: {sig_f}\n'
- f' :no-typesetting:\n')
- doctree = restructuredtext.parse(app, text)
- assert_node(doctree, (addnodes.index, nodes.target))
-
-
-@pytest.mark.parametrize(('directive', 'no_index', 'no_index_entry', 'sig_f', 'sig_g', 'index_g'), DOMAINS)
-def test_object_description_no_typesetting_twice(app, directive, no_index, no_index_entry, sig_f, sig_g, index_g):
- text = (f'.. {directive}:: {sig_f}\n'
- f' :no-typesetting:\n'
- f'.. {directive}:: {sig_g}\n'
- f' :no-typesetting:\n')
- doctree = restructuredtext.parse(app, text)
- # Note that all index nodes come before the target nodes
- assert_node(doctree, (addnodes.index, addnodes.index, nodes.target, nodes.target))
-
-
-@pytest.mark.parametrize(('directive', 'no_index', 'no_index_entry', 'sig_f', 'sig_g', 'index_g'), DOMAINS)
-def test_object_description_no_typesetting_noindex_orig(app, directive, no_index, no_index_entry, sig_f, sig_g, index_g):
- if not no_index:
- pytest.skip(f'{directive} does not support :no-index: option')
- text = (f'.. {directive}:: {sig_f}\n'
- f' :no-index:\n'
- f'.. {directive}:: {sig_g}\n')
- doctree = restructuredtext.parse(app, text)
- assert_node(doctree, (addnodes.index, addnodes.desc, addnodes.index, addnodes.desc))
- assert_node(doctree[2], addnodes.index, entries=[index_g])
-
-
-@pytest.mark.parametrize(('directive', 'no_index', 'no_index_entry', 'sig_f', 'sig_g', 'index_g'), DOMAINS)
-def test_object_description_no_typesetting_noindex(app, directive, no_index, no_index_entry, sig_f, sig_g, index_g):
- if not no_index:
- pytest.skip(f'{directive} does not support :no-index: option')
- text = (f'.. {directive}:: {sig_f}\n'
- f' :no-index:\n'
- f' :no-typesetting:\n'
- f'.. {directive}:: {sig_g}\n'
- f' :no-typesetting:\n')
- doctree = restructuredtext.parse(app, text)
- assert_node(doctree, (addnodes.index, addnodes.index, nodes.target))
- assert_node(doctree[0], addnodes.index, entries=[])
- assert_node(doctree[1], addnodes.index, entries=[index_g])
-
-
-@pytest.mark.parametrize(('directive', 'no_index', 'no_index_entry', 'sig_f', 'sig_g', 'index_g'), DOMAINS)
-def test_object_description_no_typesetting_no_index_entry(app, directive, no_index, no_index_entry, sig_f, sig_g, index_g):
- if not no_index_entry:
- pytest.skip(f'{directive} does not support :no-index-entry: option')
- text = (f'.. {directive}:: {sig_f}\n'
- f' :no-index-entry:\n'
- f' :no-typesetting:\n'
- f'.. {directive}:: {sig_g}\n'
- f' :no-typesetting:\n')
- doctree = restructuredtext.parse(app, text)
- assert_node(doctree, (addnodes.index, addnodes.index, nodes.target, nodes.target))
- assert_node(doctree[0], addnodes.index, entries=[])
- assert_node(doctree[1], addnodes.index, entries=[index_g])
-
-
-@pytest.mark.parametrize(('directive', 'no_index', 'no_index_entry', 'sig_f', 'sig_g', 'index_g'), DOMAINS)
-def test_object_description_no_typesetting_code(app, directive, no_index, no_index_entry, sig_f, sig_g, index_g):
- text = (f'.. {directive}:: {sig_f}\n'
- f' :no-typesetting:\n'
- f'.. {directive}:: {sig_g}\n'
- f' :no-typesetting:\n'
- f'.. code::\n'
- f'\n'
- f' code\n')
- doctree = restructuredtext.parse(app, text)
- # Note that all index nodes come before the targets
- assert_node(doctree, (addnodes.index, addnodes.index, nodes.target, nodes.target, nodes.literal_block))
-
-
-@pytest.mark.parametrize(('directive', 'no_index', 'no_index_entry', 'sig_f', 'sig_g', 'index_g'), DOMAINS)
-def test_object_description_no_typesetting_heading(app, directive, no_index, no_index_entry, sig_f, sig_g, index_g):
- text = (f'.. {directive}:: {sig_f}\n'
- f' :no-typesetting:\n'
- f'.. {directive}:: {sig_g}\n'
- f' :no-typesetting:\n'
- f'\n'
- f'Heading\n'
- f'=======\n')
- doctree = restructuredtext.parse(app, text)
- # Note that all index nodes come before the targets and the heading is floated before those.
- assert_node(doctree, (nodes.title, addnodes.index, addnodes.index, nodes.target, nodes.target))