~ubuntu-branches/ubuntu/hardy/python-docutils/hardy

« back to all changes in this revision

Viewing changes to test/test_rst/test_definition_lists.py

  • Committer: Bazaar Package Importer
  • Author(s): martin f. krafft
  • Date: 2006-07-10 11:45:05 UTC
  • mfrom: (2.1.4 edgy)
  • Revision ID: james.westby@ubuntu.com-20060710114505-otkhqcslevewxmz5
Tags: 0.4-3
Added build dependency on python-central (closes: #377580).

Show diffs side-by-side

added added

removed removed

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