Skip to content

Commit 88816ba

Browse files
committed
Make tests take new anchors into account
1 parent 4600143 commit 88816ba

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

tests/test_extension.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@ def test_basics(make_app, rootdir):
3838
assert section[0].astext() == 'greet'
3939
assert isinstance(section[1], nodes.paragraph)
4040
assert section[1].astext() == 'A sample command group.'
41-
assert isinstance(section[2], nodes.literal_block)
41+
assert isinstance(section[2], nodes.target)
42+
assert section[2].attributes['refid'] == 'greet'
43+
assert isinstance(section[3], nodes.literal_block)
4244

43-
assert isinstance(section[3], nodes.rubric)
44-
assert section[3].astext() == 'Commands'
45-
assert isinstance(section[4], sphinx_nodes.index)
46-
assert isinstance(section[5], sphinx_nodes.desc)
47-
assert isinstance(section[6], sphinx_nodes.index)
48-
assert isinstance(section[7], sphinx_nodes.desc)
45+
assert isinstance(section[4], nodes.rubric)
46+
assert section[4].astext() == 'Commands'
47+
assert isinstance(section[5], sphinx_nodes.index)
48+
assert isinstance(section[6], sphinx_nodes.desc)
49+
assert isinstance(section[7], sphinx_nodes.index)
50+
assert isinstance(section[8], sphinx_nodes.desc)
4951

5052

5153
def test_nested_full(make_app, rootdir):
@@ -82,23 +84,29 @@ def test_nested_full(make_app, rootdir):
8284
assert section[0].astext() == 'greet'
8385
assert isinstance(section[1], nodes.paragraph)
8486
assert section[1].astext() == 'A sample command group.'
85-
assert isinstance(section[2], nodes.literal_block)
87+
assert isinstance(section[2], nodes.target)
88+
assert section[2].attributes['refid'] == 'greet'
89+
assert isinstance(section[3], nodes.literal_block)
8690

87-
subsection_a = section[3]
91+
subsection_a = section[4]
8892
assert isinstance(subsection_a, nodes.section)
8993

9094
assert isinstance(subsection_a[0], nodes.title)
9195
assert subsection_a[0].astext() == 'hello'
9296
assert isinstance(subsection_a[1], nodes.paragraph)
9397
assert subsection_a[1].astext() == 'Greet a user.'
94-
assert isinstance(subsection_a[2], nodes.literal_block)
98+
assert isinstance(subsection_a[2], nodes.target)
99+
assert subsection_a[2].attributes['refid'] == 'greet-hello'
100+
assert isinstance(subsection_a[3], nodes.literal_block)
95101
# we don't need to verify the rest of this: that's done elsewhere
96102

97-
subsection_b = section[4]
103+
subsection_b = section[5]
98104
assert isinstance(subsection_b, nodes.section)
99105

100106
assert isinstance(subsection_b[0], nodes.title)
101107
assert subsection_b[0].astext() == 'world'
102108
assert isinstance(subsection_b[1], nodes.paragraph)
103109
assert subsection_b[1].astext() == 'Greet the world.'
104-
assert isinstance(subsection_b[2], nodes.literal_block)
110+
assert isinstance(subsection_b[2], nodes.target)
111+
assert subsection_b[2].attributes['refid'] == 'greet-world'
112+
assert isinstance(subsection_b[3], nodes.literal_block)

tests/test_formatter.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,21 +1075,29 @@ def cli_with_auto_envvars():
10751075
"""
10761076
A simple CLI with auto-env vars .
10771077
1078+
.. _cli:
1079+
10781080
.. program:: cli
10791081
.. code-block:: shell
10801082
10811083
cli [OPTIONS]
10821084
10831085
.. rubric:: Options
10841086
1087+
.. _cli-param:
1088+
10851089
.. option:: --param <param>
10861090
10871091
Help for param
10881092
1093+
.. _cli-other-param:
1094+
10891095
.. option:: --other-param <other_param>
10901096
10911097
Help for other-param
10921098
1099+
.. _cli-param-with-explicit-envvar:
1100+
10931101
.. option:: --param-with-explicit-envvar <param_with_explicit_envvar>
10941102
10951103
Help for param-with-explicit-envvar
@@ -1103,13 +1111,17 @@ def cli_with_auto_envvars():
11031111
11041112
Provide a default for :option:`--param`
11051113
1114+
.. _cli-other-param-PREFIX_OTHER_PARAM:
1115+
11061116
.. _cli-other_param-PREFIX_OTHER_PARAM:
11071117
11081118
.. envvar:: PREFIX_OTHER_PARAM
11091119
:noindex:
11101120
11111121
Provide a default for :option:`--other-param`
11121122
1123+
.. _cli-param-with-explicit-envvar-EXPLICIT_ENVVAR:
1124+
11131125
.. _cli-param_with_explicit_envvar-EXPLICIT_ENVVAR:
11141126
11151127
.. envvar:: EXPLICIT_ENVVAR

0 commit comments

Comments
 (0)