Website: add template and basic stylesheet with menu. Update buildhtml.py (and theref...
[docutils.git] / sandbox / gitpull / web_stylesheet_and_menu / test / test_parsers / test_rst / test_directives / test_topics.py
blob789c0eba007b3973f5215f9155f66cb1d6a8bf32
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 the "topic" 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['topics'] = [
21 ["""\
22 .. topic::
23 """,
24 """\
25 <document source="test data">
26 <system_message level="3" line="1" source="test data" type="ERROR">
27 <paragraph>
28 Error in "topic" directive:
29 1 argument(s) required, 0 supplied.
30 <literal_block xml:space="preserve">
31 .. topic::
32 """],
33 ["""\
34 .. topic:: Title
35 """,
36 """\
37 <document source="test data">
38 <system_message level="3" line="1" source="test data" type="ERROR">
39 <paragraph>
40 Content block expected for the "topic" directive; none found.
41 <literal_block xml:space="preserve">
42 .. topic:: Title
43 """],
44 ["""\
45 .. topic:: Title
47 Body.
48 """,
49 """\
50 <document source="test data">
51 <topic>
52 <title>
53 Title
54 <paragraph>
55 Body.
56 """],
57 ["""\
58 .. topic:: With Options
59 :class: custom
60 :name: my point
62 Body.
63 """,
64 """\
65 <document source="test data">
66 <topic classes="custom" ids="my-point" names="my\ point">
67 <title>
68 With Options
69 <paragraph>
70 Body.
71 """],
72 ["""\
73 .. topic::
75 Title
77 Body.
78 """,
79 """\
80 <document source="test data">
81 <system_message level="3" line="1" source="test data" type="ERROR">
82 <paragraph>
83 Error in "topic" directive:
84 1 argument(s) required, 0 supplied.
85 <literal_block xml:space="preserve">
86 .. topic::
87 \n\
88 Title
89 \n\
90 Body.
91 """],
92 ["""\
93 .. topic:: Title
94 Body.
95 """,
96 """\
97 <document source="test data">
98 <system_message level="3" line="1" source="test data" type="ERROR">
99 <paragraph>
100 Content block expected for the "topic" directive; none found.
101 <literal_block xml:space="preserve">
102 .. topic:: Title
103 Body.
104 """],
105 ["""\
106 .. topic::
108 Title
109 Body.
110 """,
111 """\
112 <document source="test data">
113 <system_message level="3" line="1" source="test data" type="ERROR">
114 <paragraph>
115 Error in "topic" directive:
116 1 argument(s) required, 0 supplied.
117 <literal_block xml:space="preserve">
118 .. topic::
120 Title
121 Body.
122 """],
123 ["""\
124 .. topic:: Title
126 .. topic:: Nested
128 Body.
129 """,
130 """\
131 <document source="test data">
132 <topic>
133 <title>
134 Title
135 <system_message level="3" line="3" source="test data" type="ERROR">
136 <paragraph>
137 The "topic" directive may not be used within topics or body elements.
138 <literal_block xml:space="preserve">
139 .. topic:: Nested
141 Body.
142 """],
143 ["""\
144 .. topic:: Title
146 .. topic:: Nested
148 Body.
149 More.
150 """,
151 """\
152 <document source="test data">
153 <topic>
154 <title>
155 Title
156 <system_message level="3" line="3" source="test data" type="ERROR">
157 <paragraph>
158 The "topic" directive may not be used within topics or body elements.
159 <literal_block xml:space="preserve">
160 .. topic:: Nested
162 Body.
163 <system_message level="2" line="6" source="test data" type="WARNING">
164 <paragraph>
165 Explicit markup ends without a blank line; unexpected unindent.
166 <paragraph>
167 More.
168 """],
169 ["""\
170 .. topic:: Title
172 .. topic:: Nested
174 Body.
176 More.
178 More.
179 """,
180 """\
181 <document source="test data">
182 <topic>
183 <title>
184 Title
185 <system_message level="3" line="3" source="test data" type="ERROR">
186 <paragraph>
187 The "topic" directive may not be used within topics or body elements.
188 <literal_block xml:space="preserve">
189 .. topic:: Nested
191 Body.
192 <paragraph>
193 More.
194 <paragraph>
195 More.
196 """],
197 ["""\
198 .. topic:: First
200 Body
202 .. topic:: Second
204 Body.
205 """,
206 """\
207 <document source="test data">
208 <topic>
209 <title>
210 First
211 <paragraph>
212 Body
213 <topic>
214 <title>
215 Second
216 <paragraph>
217 Body.
218 """],
219 ["""\
220 .. sidebar:: Title
221 :subtitle: Outer
223 .. topic:: Nested
225 Body.
227 More.
229 More.
230 """,
231 """\
232 <document source="test data">
233 <sidebar>
234 <title>
235 Title
236 <subtitle>
237 Outer
238 <topic>
239 <title>
240 Nested
241 <paragraph>
242 Body.
243 <paragraph>
244 More.
245 <paragraph>
246 More.
247 """],
251 if __name__ == '__main__':
252 import unittest
253 unittest.main(defaultTest='suite')