Drop 2.4 and 2.5 compatibility code, part 2.
[docutils.git] / docutils / test / test_parsers / test_rst / test_definition_lists.py
blob76251b6cbc19e8eab861b37b317f241a086d25ef
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 states.py.
9 """
11 from __init__ import DocutilsTestSupport
13 def suite():
14 s = DocutilsTestSupport.ParserTestSuite()
15 s.generateTests(totest)
16 return s
18 totest = {}
20 totest['definition_lists'] = [
21 ["""\
22 term
23 definition
24 """,
25 """\
26 <document source="test data">
27 <definition_list>
28 <definition_list_item>
29 <term>
30 term
31 <definition>
32 <paragraph>
33 definition
34 """],
35 ["""\
36 term
37 definition
39 paragraph
40 """,
41 """\
42 <document source="test data">
43 <definition_list>
44 <definition_list_item>
45 <term>
46 term
47 <definition>
48 <paragraph>
49 definition
50 <paragraph>
51 paragraph
52 """],
53 ["""\
54 term
55 definition
56 no blank line
57 """,
58 """\
59 <document source="test data">
60 <definition_list>
61 <definition_list_item>
62 <term>
63 term
64 <definition>
65 <paragraph>
66 definition
67 <system_message level="2" line="3" source="test data" type="WARNING">
68 <paragraph>
69 Definition list ends without a blank line; unexpected unindent.
70 <paragraph>
71 no blank line
72 """],
73 ["""\
74 A paragraph::
75 A literal block without a blank line first?
76 """,
77 """\
78 <document source="test data">
79 <definition_list>
80 <definition_list_item>
81 <term>
82 A paragraph::
83 <definition>
84 <system_message level="1" line="2" source="test data" type="INFO">
85 <paragraph>
86 Blank line missing before literal block (after the "::")? Interpreted as a definition list item.
87 <paragraph>
88 A literal block without a blank line first?
89 """],
90 ["""\
91 this is not a term;
92 a term may only be one line long
93 this is not a definition
94 """,
95 """\
96 <document source="test data">
97 <paragraph>
98 this is not a term;
99 a term may only be one line long
100 <system_message level="3" line="3" source="test data" type="ERROR">
101 <paragraph>
102 Unexpected indentation.
103 <block_quote>
104 <paragraph>
105 this is not a definition
106 """],
107 ["""\
108 term 1
109 definition 1
111 term 2
112 definition 2
113 """,
114 """\
115 <document source="test data">
116 <definition_list>
117 <definition_list_item>
118 <term>
119 term 1
120 <definition>
121 <paragraph>
122 definition 1
123 <definition_list_item>
124 <term>
125 term 2
126 <definition>
127 <paragraph>
128 definition 2
129 """],
130 ["""\
131 term 1
132 definition 1 (no blank line below)
133 term 2
134 definition 2
135 """,
136 """\
137 <document source="test data">
138 <definition_list>
139 <definition_list_item>
140 <term>
141 term 1
142 <definition>
143 <paragraph>
144 definition 1 (no blank line below)
145 <definition_list_item>
146 <term>
147 term 2
148 <definition>
149 <paragraph>
150 definition 2
151 """],
152 ["""\
153 term 1
154 definition 1 (no blank line below)
155 term 2
156 definition 2
157 No blank line after the definition list.
158 """,
159 """\
160 <document source="test data">
161 <definition_list>
162 <definition_list_item>
163 <term>
164 term 1
165 <definition>
166 <paragraph>
167 definition 1 (no blank line below)
168 <definition_list_item>
169 <term>
170 term 2
171 <definition>
172 <paragraph>
173 definition 2
174 <system_message level="2" line="5" source="test data" type="WARNING">
175 <paragraph>
176 Definition list ends without a blank line; unexpected unindent.
177 <paragraph>
178 No blank line after the definition list.
179 """],
180 ["""\
181 term 1
182 definition 1
184 term 1a
185 definition 1a
187 term 1b
188 definition 1b
190 term 2
191 definition 2
193 paragraph
194 """,
195 """\
196 <document source="test data">
197 <definition_list>
198 <definition_list_item>
199 <term>
200 term 1
201 <definition>
202 <paragraph>
203 definition 1
204 <definition_list>
205 <definition_list_item>
206 <term>
207 term 1a
208 <definition>
209 <paragraph>
210 definition 1a
211 <definition_list_item>
212 <term>
213 term 1b
214 <definition>
215 <paragraph>
216 definition 1b
217 <definition_list_item>
218 <term>
219 term 2
220 <definition>
221 <paragraph>
222 definition 2
223 <paragraph>
224 paragraph
225 """],
226 ["""\
227 Term : classifier
228 The ' : ' indicates a classifier in
229 definition list item terms only.
230 """,
231 """\
232 <document source="test data">
233 <definition_list>
234 <definition_list_item>
235 <term>
236 Term
237 <classifier>
238 classifier
239 <definition>
240 <paragraph>
241 The ' : ' indicates a classifier in
242 definition list item terms only.
243 """],
244 ["""\
245 Term: not a classifier
246 Because there's no space before the colon.
247 Term :not a classifier
248 Because there's no space after the colon.
249 Term \: not a classifier
250 Because the colon is escaped.
251 """,
252 """\
253 <document source="test data">
254 <definition_list>
255 <definition_list_item>
256 <term>
257 Term: not a classifier
258 <definition>
259 <paragraph>
260 Because there's no space before the colon.
261 <definition_list_item>
262 <term>
263 Term :not a classifier
264 <definition>
265 <paragraph>
266 Because there's no space after the colon.
267 <definition_list_item>
268 <term>
269 Term : not a classifier
270 <definition>
271 <paragraph>
272 Because the colon is escaped.
273 """],
274 ["""\
275 ``Term : not a classifier``
276 Because the ' : ' is inside an inline literal.
277 """,
278 """\
279 <document source="test data">
280 <definition_list>
281 <definition_list_item>
282 <term>
283 <literal>
284 Term : not a classifier
285 <definition>
286 <paragraph>
287 Because the ' : ' is inside an inline literal.
288 """],
289 ["""\
290 Term `with *inline ``text **errors : classifier `with *errors ``too
291 Definition `with *inline ``text **markup errors.
292 """,
293 """\
294 <document source="test data">
295 <definition_list>
296 <definition_list_item>
297 <term>
298 Term \n\
299 <problematic ids="id2" refid="id1">
301 with \n\
302 <problematic ids="id4" refid="id3">
304 inline \n\
305 <problematic ids="id6" refid="id5">
307 text \n\
308 <problematic ids="id8" refid="id7">
310 errors
311 <classifier>
312 classifier \n\
313 <problematic ids="id10" refid="id9">
315 with \n\
316 <problematic ids="id12" refid="id11">
318 errors \n\
319 <problematic ids="id14" refid="id13">
322 <definition>
323 <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
324 <paragraph>
325 Inline interpreted text or phrase reference start-string without end-string.
326 <system_message backrefs="id4" ids="id3" level="2" line="1" source="test data" type="WARNING">
327 <paragraph>
328 Inline emphasis start-string without end-string.
329 <system_message backrefs="id6" ids="id5" level="2" line="1" source="test data" type="WARNING">
330 <paragraph>
331 Inline literal start-string without end-string.
332 <system_message backrefs="id8" ids="id7" level="2" line="1" source="test data" type="WARNING">
333 <paragraph>
334 Inline strong start-string without end-string.
335 <system_message backrefs="id10" ids="id9" level="2" line="1" source="test data" type="WARNING">
336 <paragraph>
337 Inline interpreted text or phrase reference start-string without end-string.
338 <system_message backrefs="id12" ids="id11" level="2" line="1" source="test data" type="WARNING">
339 <paragraph>
340 Inline emphasis start-string without end-string.
341 <system_message backrefs="id14" ids="id13" level="2" line="1" source="test data" type="WARNING">
342 <paragraph>
343 Inline literal start-string without end-string.
344 <paragraph>
345 Definition \n\
346 <problematic ids="id16" refid="id15">
348 with \n\
349 <problematic ids="id18" refid="id17">
351 inline \n\
352 <problematic ids="id20" refid="id19">
354 text \n\
355 <problematic ids="id22" refid="id21">
357 markup errors.
358 <system_message backrefs="id16" ids="id15" level="2" line="2" source="test data" type="WARNING">
359 <paragraph>
360 Inline interpreted text or phrase reference start-string without end-string.
361 <system_message backrefs="id18" ids="id17" level="2" line="2" source="test data" type="WARNING">
362 <paragraph>
363 Inline emphasis start-string without end-string.
364 <system_message backrefs="id20" ids="id19" level="2" line="2" source="test data" type="WARNING">
365 <paragraph>
366 Inline literal start-string without end-string.
367 <system_message backrefs="id22" ids="id21" level="2" line="2" source="test data" type="WARNING">
368 <paragraph>
369 Inline strong start-string without end-string.
370 """],
371 ["""\
372 Term : classifier one : classifier two
373 Definition
374 """,
375 """\
376 <document source="test data">
377 <definition_list>
378 <definition_list_item>
379 <term>
380 Term
381 <classifier>
382 classifier one
383 <classifier>
384 classifier two
385 <definition>
386 <paragraph>
387 Definition
388 """],
391 if __name__ == '__main__':
392 import unittest
393 unittest.main(defaultTest='suite')