~ubuntu-branches/ubuntu/jaunty/python-docutils/jaunty

« back to all changes in this revision

Viewing changes to test/test_rst/test_section_headers.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.2 $
7
 
:Date: $Date: 2002/04/25 03:43:45 $
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['section_headers'] = [
23
 
["""\
24
 
Title
25
 
=====
26
 
 
27
 
Paragraph.
28
 
""",
29
 
"""\
30
 
<document>
31
 
    <section id="title" name="title">
32
 
        <title>
33
 
            Title
34
 
        <paragraph>
35
 
            Paragraph.
36
 
"""],
37
 
["""\
38
 
Title
39
 
=====
40
 
Paragraph (no blank line).
41
 
""",
42
 
"""\
43
 
<document>
44
 
    <section id="title" name="title">
45
 
        <title>
46
 
            Title
47
 
        <paragraph>
48
 
            Paragraph (no blank line).
49
 
"""],
50
 
["""\
51
 
Paragraph.
52
 
 
53
 
Title
54
 
=====
55
 
 
56
 
Paragraph.
57
 
""",
58
 
"""\
59
 
<document>
60
 
    <paragraph>
61
 
        Paragraph.
62
 
    <section id="title" name="title">
63
 
        <title>
64
 
            Title
65
 
        <paragraph>
66
 
            Paragraph.
67
 
"""],
68
 
["""\
69
 
Test unexpected section titles.
70
 
 
71
 
    Title
72
 
    =====
73
 
    Paragraph.
74
 
 
75
 
    -----
76
 
    Title
77
 
    -----
78
 
    Paragraph.
79
 
""",
80
 
"""\
81
 
<document>
82
 
    <paragraph>
83
 
        Test unexpected section titles.
84
 
    <block_quote>
85
 
        <system_message level="4" type="SEVERE">
86
 
            <paragraph>
87
 
                Unexpected section title at line 4.
88
 
            <literal_block>
89
 
                Title
90
 
                =====
91
 
        <paragraph>
92
 
            Paragraph.
93
 
        <system_message level="4" type="SEVERE">
94
 
            <paragraph>
95
 
                Unexpected section title or transition at line 7.
96
 
            <literal_block>
97
 
                -----
98
 
        <system_message level="4" type="SEVERE">
99
 
            <paragraph>
100
 
                Unexpected section title at line 9.
101
 
            <literal_block>
102
 
                Title
103
 
                -----
104
 
        <paragraph>
105
 
            Paragraph.
106
 
"""],
107
 
["""\
108
 
Title
109
 
====
110
 
 
111
 
Test short underline.
112
 
""",
113
 
"""\
114
 
<document>
115
 
    <system_message level="1" type="INFO">
116
 
        <paragraph>
117
 
            Title underline too short at line 2.
118
 
        <literal_block>
119
 
            Title
120
 
            ====
121
 
    <section id="title" name="title">
122
 
        <title>
123
 
            Title
124
 
        <paragraph>
125
 
            Test short underline.
126
 
"""],
127
 
["""\
128
 
=====
129
 
Title
130
 
=====
131
 
 
132
 
Test overline title.
133
 
""",
134
 
"""\
135
 
<document>
136
 
    <section id="title" name="title">
137
 
        <title>
138
 
            Title
139
 
        <paragraph>
140
 
            Test overline title.
141
 
"""],
142
 
["""\
143
 
=======
144
 
 Title
145
 
=======
146
 
 
147
 
Test overline title with inset.
148
 
""",
149
 
"""\
150
 
<document>
151
 
    <section id="title" name="title">
152
 
        <title>
153
 
            Title
154
 
        <paragraph>
155
 
            Test overline title with inset.
156
 
"""],
157
 
["""\
158
 
========================
159
 
 Test Missing Underline
160
 
""",
161
 
"""\
162
 
<document>
163
 
    <system_message level="4" type="SEVERE">
164
 
        <paragraph>
165
 
            Incomplete section title at line 1.
166
 
        <literal_block>
167
 
            ========================
168
 
             Test Missing Underline
169
 
"""],
170
 
["""\
171
 
========================
172
 
 Test Missing Underline
173
 
 
174
 
""",
175
 
"""\
176
 
<document>
177
 
    <system_message level="4" type="SEVERE">
178
 
        <paragraph>
179
 
            Missing underline for overline at line 1.
180
 
        <literal_block>
181
 
            ========================
182
 
             Test Missing Underline
183
 
"""],
184
 
["""\
185
 
=======
186
 
 Title
187
 
 
188
 
Test missing underline, with paragraph.
189
 
""",
190
 
"""\
191
 
<document>
192
 
    <system_message level="4" type="SEVERE">
193
 
        <paragraph>
194
 
            Missing underline for overline at line 1.
195
 
        <literal_block>
196
 
            =======
197
 
             Title
198
 
    <paragraph>
199
 
        Test missing underline, with paragraph.
200
 
"""],
201
 
["""\
202
 
=======
203
 
 Long    Title
204
 
=======
205
 
 
206
 
Test long title and space normalization.
207
 
""",
208
 
"""\
209
 
<document>
210
 
    <system_message level="1" type="INFO">
211
 
        <paragraph>
212
 
            Title overline too short at line 1.
213
 
        <literal_block>
214
 
            =======
215
 
             Long    Title
216
 
            =======
217
 
    <section id="long-title" name="long title">
218
 
        <title>
219
 
            Long    Title
220
 
        <paragraph>
221
 
            Test long title and space normalization.
222
 
"""],
223
 
["""\
224
 
=======
225
 
 Title
226
 
-------
227
 
 
228
 
Paragraph.
229
 
""",
230
 
"""\
231
 
<document>
232
 
    <system_message level="4" type="SEVERE">
233
 
        <paragraph>
234
 
            Title overline & underline mismatch at line 1.
235
 
        <literal_block>
236
 
            =======
237
 
             Title
238
 
            -------
239
 
    <paragraph>
240
 
        Paragraph.
241
 
"""],
242
 
["""\
243
 
========================
244
 
 
245
 
========================
246
 
 
247
 
Test missing titles; blank line in-between.
248
 
 
249
 
========================
250
 
 
251
 
========================
252
 
""",
253
 
"""\
254
 
<document>
255
 
    <system_message level="3" type="ERROR">
256
 
        <paragraph>
257
 
            Document or section may not begin with a transition (line 1).
258
 
    <transition>
259
 
    <system_message level="3" type="ERROR">
260
 
        <paragraph>
261
 
            At least one body element must separate transitions; adjacent transitions at line 3.
262
 
    <transition>
263
 
    <paragraph>
264
 
        Test missing titles; blank line in-between.
265
 
    <transition>
266
 
    <transition>
267
 
    <system_message level="3" type="ERROR">
268
 
        <paragraph>
269
 
            Document or section may not end with a transition (line 9).
270
 
"""],
271
 
["""\
272
 
========================
273
 
========================
274
 
 
275
 
Test missing titles; nothing in-between.
276
 
 
277
 
========================
278
 
========================
279
 
""",
280
 
"""\
281
 
<document>
282
 
    <system_message level="3" type="ERROR">
283
 
        <paragraph>
284
 
            Invalid section title or transition marker at line 1.
285
 
        <literal_block>
286
 
            ========================
287
 
            ========================
288
 
    <paragraph>
289
 
        Test missing titles; nothing in-between.
290
 
    <system_message level="3" type="ERROR">
291
 
        <paragraph>
292
 
            Invalid section title or transition marker at line 6.
293
 
        <literal_block>
294
 
            ========================
295
 
            ========================
296
 
"""],
297
 
["""\
298
 
.. Test return to existing, highest-level section (Title 3).
299
 
 
300
 
Title 1
301
 
=======
302
 
Paragraph 1.
303
 
 
304
 
Title 2
305
 
-------
306
 
Paragraph 2.
307
 
 
308
 
Title 3
309
 
=======
310
 
Paragraph 3.
311
 
 
312
 
Title 4
313
 
-------
314
 
Paragraph 4.
315
 
""",
316
 
"""\
317
 
<document>
318
 
    <comment>
319
 
        Test return to existing, highest-level section (Title 3).
320
 
    <section id="title-1" name="title 1">
321
 
        <title>
322
 
            Title 1
323
 
        <paragraph>
324
 
            Paragraph 1.
325
 
        <section id="title-2" name="title 2">
326
 
            <title>
327
 
                Title 2
328
 
            <paragraph>
329
 
                Paragraph 2.
330
 
    <section id="title-3" name="title 3">
331
 
        <title>
332
 
            Title 3
333
 
        <paragraph>
334
 
            Paragraph 3.
335
 
        <section id="title-4" name="title 4">
336
 
            <title>
337
 
                Title 4
338
 
            <paragraph>
339
 
                Paragraph 4.
340
 
"""],
341
 
["""\
342
 
Test return to existing, highest-level section (Title 3, with overlines).
343
 
 
344
 
=======
345
 
Title 1
346
 
=======
347
 
Paragraph 1.
348
 
 
349
 
-------
350
 
Title 2
351
 
-------
352
 
Paragraph 2.
353
 
 
354
 
=======
355
 
Title 3
356
 
=======
357
 
Paragraph 3.
358
 
 
359
 
-------
360
 
Title 4
361
 
-------
362
 
Paragraph 4.
363
 
""",
364
 
"""\
365
 
<document>
366
 
    <paragraph>
367
 
        Test return to existing, highest-level section (Title 3, with overlines).
368
 
    <section id="title-1" name="title 1">
369
 
        <title>
370
 
            Title 1
371
 
        <paragraph>
372
 
            Paragraph 1.
373
 
        <section id="title-2" name="title 2">
374
 
            <title>
375
 
                Title 2
376
 
            <paragraph>
377
 
                Paragraph 2.
378
 
    <section id="title-3" name="title 3">
379
 
        <title>
380
 
            Title 3
381
 
        <paragraph>
382
 
            Paragraph 3.
383
 
        <section id="title-4" name="title 4">
384
 
            <title>
385
 
                Title 4
386
 
            <paragraph>
387
 
                Paragraph 4.
388
 
"""],
389
 
["""\
390
 
Test return to existing, higher-level section (Title 4).
391
 
 
392
 
Title 1
393
 
=======
394
 
Paragraph 1.
395
 
 
396
 
Title 2
397
 
-------
398
 
Paragraph 2.
399
 
 
400
 
Title 3
401
 
```````
402
 
Paragraph 3.
403
 
 
404
 
Title 4
405
 
-------
406
 
Paragraph 4.
407
 
""",
408
 
"""\
409
 
<document>
410
 
    <paragraph>
411
 
        Test return to existing, higher-level section (Title 4).
412
 
    <section id="title-1" name="title 1">
413
 
        <title>
414
 
            Title 1
415
 
        <paragraph>
416
 
            Paragraph 1.
417
 
        <section id="title-2" name="title 2">
418
 
            <title>
419
 
                Title 2
420
 
            <paragraph>
421
 
                Paragraph 2.
422
 
            <section id="title-3" name="title 3">
423
 
                <title>
424
 
                    Title 3
425
 
                <paragraph>
426
 
                    Paragraph 3.
427
 
        <section id="title-4" name="title 4">
428
 
            <title>
429
 
                Title 4
430
 
            <paragraph>
431
 
                Paragraph 4.
432
 
"""],
433
 
["""\
434
 
Test bad subsection order (Title 4).
435
 
 
436
 
Title 1
437
 
=======
438
 
Paragraph 1.
439
 
 
440
 
Title 2
441
 
-------
442
 
Paragraph 2.
443
 
 
444
 
Title 3
445
 
=======
446
 
Paragraph 3.
447
 
 
448
 
Title 4
449
 
```````
450
 
Paragraph 4.
451
 
""",
452
 
"""\
453
 
<document>
454
 
    <paragraph>
455
 
        Test bad subsection order (Title 4).
456
 
    <section id="title-1" name="title 1">
457
 
        <title>
458
 
            Title 1
459
 
        <paragraph>
460
 
            Paragraph 1.
461
 
        <section id="title-2" name="title 2">
462
 
            <title>
463
 
                Title 2
464
 
            <paragraph>
465
 
                Paragraph 2.
466
 
    <section id="title-3" name="title 3">
467
 
        <title>
468
 
            Title 3
469
 
        <paragraph>
470
 
            Paragraph 3.
471
 
        <system_message level="4" type="SEVERE">
472
 
            <paragraph>
473
 
                Title level inconsistent at line 15:
474
 
            <literal_block>
475
 
                Title 4
476
 
                ```````
477
 
        <paragraph>
478
 
            Paragraph 4.
479
 
"""],
480
 
["""\
481
 
Test bad subsection order (Title 4, with overlines).
482
 
 
483
 
=======
484
 
Title 1
485
 
=======
486
 
Paragraph 1.
487
 
 
488
 
-------
489
 
Title 2
490
 
-------
491
 
Paragraph 2.
492
 
 
493
 
=======
494
 
Title 3
495
 
=======
496
 
Paragraph 3.
497
 
 
498
 
```````
499
 
Title 4
500
 
```````
501
 
Paragraph 4.
502
 
""",
503
 
"""\
504
 
<document>
505
 
    <paragraph>
506
 
        Test bad subsection order (Title 4, with overlines).
507
 
    <section id="title-1" name="title 1">
508
 
        <title>
509
 
            Title 1
510
 
        <paragraph>
511
 
            Paragraph 1.
512
 
        <section id="title-2" name="title 2">
513
 
            <title>
514
 
                Title 2
515
 
            <paragraph>
516
 
                Paragraph 2.
517
 
    <section id="title-3" name="title 3">
518
 
        <title>
519
 
            Title 3
520
 
        <paragraph>
521
 
            Paragraph 3.
522
 
        <system_message level="4" type="SEVERE">
523
 
            <paragraph>
524
 
                Title level inconsistent at line 19:
525
 
            <literal_block>
526
 
                ```````
527
 
                Title 4
528
 
                ```````
529
 
        <paragraph>
530
 
            Paragraph 4.
531
 
"""],
532
 
["""\
533
 
Title containing *inline* ``markup``
534
 
====================================
535
 
 
536
 
Paragraph.
537
 
""",
538
 
"""\
539
 
<document>
540
 
    <section id="title-containing-inline-markup" name="title containing inline markup">
541
 
        <title>
542
 
            Title containing \n\
543
 
            <emphasis>
544
 
                inline
545
 
             \n\
546
 
            <literal>
547
 
                markup
548
 
        <paragraph>
549
 
            Paragraph.
550
 
"""],
551
 
]
552
 
 
553
 
if __name__ == '__main__':
554
 
    import unittest
555
 
    unittest.main(defaultTest='suite')