Spelling fixes
[docutils.git] / test / test_parsers / test_rst / test_directives / test_contents.py
blobf0d02e05e4fa30999fd1001b4a1773409a3fd454
1 #! /usr/bin/env python
3 # $Id$
4 # Author: David Goodger <goodger@python.org>
5 # Copyright: This module has been placed in the public domain.
7 """
8 Tests for parts.py contents directive.
9 """
11 from __init__ import DocutilsTestSupport
13 def suite():
14 s = DocutilsTestSupport.ParserTestSuite()
15 s.generateTests(totest)
16 return s
18 totest = {}
20 totest['contents'] = [
21 ["""\
22 .. contents::
23 """,
24 """\
25 <document source="test data">
26 <topic classes="contents" ids="contents" names="contents">
27 <title>
28 Contents
29 <pending>
30 .. internal attributes:
31 .transform: docutils.transforms.parts.Contents
32 .details:
33 """],
34 ["""\
35 .. contents:: Table of Contents
36 """,
37 """\
38 <document source="test data">
39 <topic classes="contents" ids="table-of-contents" names="table\ of\ contents">
40 <title>
41 Table of Contents
42 <pending>
43 .. internal attributes:
44 .transform: docutils.transforms.parts.Contents
45 .details:
46 """],
47 ["""\
48 .. contents::
49 Table of Contents
50 """,
51 """\
52 <document source="test data">
53 <topic classes="contents" ids="table-of-contents" names="table\ of\ contents">
54 <title>
55 Table of Contents
56 <pending>
57 .. internal attributes:
58 .transform: docutils.transforms.parts.Contents
59 .details:
60 """],
61 ["""\
62 .. contents:: Table
64 Contents
65 """,
66 """\
67 <document source="test data">
68 <topic classes="contents" ids="table-of-contents" names="table\ of\ contents">
69 <title>
70 Table
72 Contents
73 <pending>
74 .. internal attributes:
75 .transform: docutils.transforms.parts.Contents
76 .details:
77 """],
78 ["""\
79 .. contents:: *Table* of ``Contents``
80 """,
81 """\
82 <document source="test data">
83 <topic classes="contents" ids="table-of-contents" names="table\ of\ contents">
84 <title>
85 <emphasis>
86 Table
87 of
88 <literal>
89 Contents
90 <pending>
91 .. internal attributes:
92 .transform: docutils.transforms.parts.Contents
93 .details:
94 """],
95 ["""\
96 .. contents::
97 :depth: 2
98 :local:
99 """,
100 """\
101 <document source="test data">
102 <topic classes="contents local" ids="contents" names="contents">
103 <pending>
104 .. internal attributes:
105 .transform: docutils.transforms.parts.Contents
106 .details:
107 depth: 2
108 local: None
109 """],
110 ["""\
111 .. contents::
112 :local: arg
113 """,
114 """\
115 <document source="test data">
116 <system_message level="3" line="1" source="test data" type="ERROR">
117 <paragraph>
118 Error in "contents" directive:
119 invalid option value: (option: "local"; value: 'arg')
120 no argument is allowed; "arg" supplied.
121 <literal_block xml:space="preserve">
122 .. contents::
123 :local: arg
124 """],
125 ["""\
126 .. contents:: Table of Contents
127 :local:
128 :depth: 2
129 :backlinks: none
130 """,
131 """\
132 <document source="test data">
133 <topic classes="contents local" ids="table-of-contents" names="table\ of\ contents">
134 <title>
135 Table of Contents
136 <pending>
137 .. internal attributes:
138 .transform: docutils.transforms.parts.Contents
139 .details:
140 backlinks: None
141 depth: 2
142 local: None
143 """],
144 ["""\
145 .. contents::
146 :depth: two
147 """,
148 """\
149 <document source="test data">
150 <system_message level="3" line="1" source="test data" type="ERROR">
151 <paragraph>
152 Error in "contents" directive:
153 invalid option value: (option: "depth"; value: 'two')
155 <literal_block xml:space="preserve">
156 .. contents::
157 :depth: two
158 """ % DocutilsTestSupport.exception_data(int, "two")[1][0]],
159 ["""\
160 .. contents::
161 :width: 2
162 """,
163 """\
164 <document source="test data">
165 <system_message level="3" line="1" source="test data" type="ERROR">
166 <paragraph>
167 Error in "contents" directive:
168 unknown option: "width".
169 <literal_block xml:space="preserve">
170 .. contents::
171 :width: 2
172 """],
173 ["""\
174 .. contents::
175 :backlinks: no way!
176 """,
177 """\
178 <document source="test data">
179 <system_message level="3" line="1" source="test data" type="ERROR">
180 <paragraph>
181 Error in "contents" directive:
182 invalid option value: (option: "backlinks"; value: 'no way!')
183 "no way!" unknown; choose from "top", "entry", or "none".
184 <literal_block xml:space="preserve">
185 .. contents::
186 :backlinks: no way!
187 """],
188 ["""\
189 .. contents::
190 :backlinks:
191 """,
192 """\
193 <document source="test data">
194 <system_message level="3" line="1" source="test data" type="ERROR">
195 <paragraph>
196 Error in "contents" directive:
197 invalid option value: (option: "backlinks"; value: None)
198 must supply an argument; choose from "top", "entry", or "none".
199 <literal_block xml:space="preserve">
200 .. contents::
201 :backlinks:
202 """],
203 ["""\
204 * .. contents::
205 """,
206 """\
207 <document source="test data">
208 <bullet_list bullet="*">
209 <list_item>
210 <system_message level="3" line="1" source="test data" type="ERROR">
211 <paragraph>
212 The "contents" directive may not be used within topics or body elements.
213 <literal_block xml:space="preserve">
214 .. contents::
215 """],
216 ["""\
217 .. sidebar:: containing contents
219 .. contents::
220 """,
221 """\
222 <document source="test data">
223 <sidebar>
224 <title>
225 containing contents
226 <topic classes="contents" ids="contents" names="contents">
227 <title>
228 Contents
229 <pending>
230 .. internal attributes:
231 .transform: docutils.transforms.parts.Contents
232 .details:
233 """],
237 if __name__ == '__main__':
238 import unittest
239 unittest.main(defaultTest='suite')