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

« back to all changes in this revision

Viewing changes to test/test_rst/test_tables.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.3 $
7
 
:Date: $Date: 2002/07/18 01:47:49 $
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['full_tables'] = [
23
 
["""\
24
 
+-------------------------------------+
25
 
| A table with one cell and one line. |
26
 
+-------------------------------------+
27
 
""",
28
 
"""\
29
 
<document>
30
 
    <table>
31
 
        <tgroup cols="1">
32
 
            <colspec colwidth="37">
33
 
            <tbody>
34
 
                <row>
35
 
                    <entry>
36
 
                        <paragraph>
37
 
                            A table with one cell and one line.
38
 
"""],
39
 
["""\
40
 
+-----------------------+
41
 
| A table with one cell |
42
 
| and two lines.        |
43
 
+-----------------------+
44
 
""",
45
 
"""\
46
 
<document>
47
 
    <table>
48
 
        <tgroup cols="1">
49
 
            <colspec colwidth="23">
50
 
            <tbody>
51
 
                <row>
52
 
                    <entry>
53
 
                        <paragraph>
54
 
                            A table with one cell
55
 
                            and two lines.
56
 
"""],
57
 
["""\
58
 
+-----------------------+
59
 
| A malformed table. |
60
 
+-----------------------+
61
 
""",
62
 
"""\
63
 
<document>
64
 
    <system_message level="3" type="ERROR">
65
 
        <paragraph>
66
 
            Malformed table at line 1; formatting as a literal block.
67
 
    <literal_block>
68
 
        +-----------------------+
69
 
        | A malformed table. |
70
 
        +-----------------------+
71
 
"""],
72
 
["""\
73
 
+------------------------+
74
 
| A well-formed | table. |
75
 
+------------------------+
76
 
 
77
 
+------------------------+
78
 
| This +----------+ too! |
79
 
+------------------------+
80
 
""",
81
 
"""\
82
 
<document>
83
 
    <table>
84
 
        <tgroup cols="1">
85
 
            <colspec colwidth="24">
86
 
            <tbody>
87
 
                <row>
88
 
                    <entry>
89
 
                        <paragraph>
90
 
                            A well-formed | table.
91
 
    <table>
92
 
        <tgroup cols="1">
93
 
            <colspec colwidth="24">
94
 
            <tbody>
95
 
                <row>
96
 
                    <entry>
97
 
                        <paragraph>
98
 
                            This +----------+ too!
99
 
"""],
100
 
["""\
101
 
+--------------+--------------+
102
 
| A table with | two columns. |
103
 
+--------------+--------------+
104
 
""",
105
 
"""\
106
 
<document>
107
 
    <table>
108
 
        <tgroup cols="2">
109
 
            <colspec colwidth="14">
110
 
            <colspec colwidth="14">
111
 
            <tbody>
112
 
                <row>
113
 
                    <entry>
114
 
                        <paragraph>
115
 
                            A table with
116
 
                    <entry>
117
 
                        <paragraph>
118
 
                            two columns.
119
 
"""],
120
 
["""\
121
 
+--------------+
122
 
| A table with |
123
 
+--------------+
124
 
| two rows.    |
125
 
+--------------+
126
 
""",
127
 
"""\
128
 
<document>
129
 
    <table>
130
 
        <tgroup cols="1">
131
 
            <colspec colwidth="14">
132
 
            <tbody>
133
 
                <row>
134
 
                    <entry>
135
 
                        <paragraph>
136
 
                            A table with
137
 
                <row>
138
 
                    <entry>
139
 
                        <paragraph>
140
 
                            two rows.
141
 
"""],
142
 
["""\
143
 
+--------------+-------------+
144
 
| A table with | two columns |
145
 
+--------------+-------------+
146
 
| and          | two rows.   |
147
 
+--------------+-------------+
148
 
""",
149
 
"""\
150
 
<document>
151
 
    <table>
152
 
        <tgroup cols="2">
153
 
            <colspec colwidth="14">
154
 
            <colspec colwidth="13">
155
 
            <tbody>
156
 
                <row>
157
 
                    <entry>
158
 
                        <paragraph>
159
 
                            A table with
160
 
                    <entry>
161
 
                        <paragraph>
162
 
                            two columns
163
 
                <row>
164
 
                    <entry>
165
 
                        <paragraph>
166
 
                            and
167
 
                    <entry>
168
 
                        <paragraph>
169
 
                            two rows.
170
 
"""],
171
 
["""\
172
 
+--------------+---------------+
173
 
| A table with | two columns,  |
174
 
+--------------+---------------+
175
 
| two rows, and a column span. |
176
 
+------------------------------+
177
 
""",
178
 
"""\
179
 
<document>
180
 
    <table>
181
 
        <tgroup cols="2">
182
 
            <colspec colwidth="14">
183
 
            <colspec colwidth="15">
184
 
            <tbody>
185
 
                <row>
186
 
                    <entry>
187
 
                        <paragraph>
188
 
                            A table with
189
 
                    <entry>
190
 
                        <paragraph>
191
 
                            two columns,
192
 
                <row>
193
 
                    <entry morecols="1">
194
 
                        <paragraph>
195
 
                            two rows, and a column span.
196
 
"""],
197
 
["""\
198
 
+--------------------------+
199
 
| A table with three rows, |
200
 
+------------+-------------+
201
 
| and two    | columns.    |
202
 
+------------+-------------+
203
 
| First and last rows      |
204
 
| contains column spans.   |
205
 
+--------------------------+
206
 
""",
207
 
"""\
208
 
<document>
209
 
    <table>
210
 
        <tgroup cols="2">
211
 
            <colspec colwidth="12">
212
 
            <colspec colwidth="13">
213
 
            <tbody>
214
 
                <row>
215
 
                    <entry morecols="1">
216
 
                        <paragraph>
217
 
                            A table with three rows,
218
 
                <row>
219
 
                    <entry>
220
 
                        <paragraph>
221
 
                            and two
222
 
                    <entry>
223
 
                        <paragraph>
224
 
                            columns.
225
 
                <row>
226
 
                    <entry morecols="1">
227
 
                        <paragraph>
228
 
                            First and last rows
229
 
                            contains column spans.
230
 
"""],
231
 
["""\
232
 
+--------------+--------------+
233
 
| A table with | two columns, |
234
 
+--------------+ and a row    |
235
 
| two rows,    | span.        |
236
 
+--------------+--------------+
237
 
""",
238
 
"""\
239
 
<document>
240
 
    <table>
241
 
        <tgroup cols="2">
242
 
            <colspec colwidth="14">
243
 
            <colspec colwidth="14">
244
 
            <tbody>
245
 
                <row>
246
 
                    <entry>
247
 
                        <paragraph>
248
 
                            A table with
249
 
                    <entry morerows="1">
250
 
                        <paragraph>
251
 
                            two columns,
252
 
                            and a row
253
 
                            span.
254
 
                <row>
255
 
                    <entry>
256
 
                        <paragraph>
257
 
                            two rows,
258
 
"""],
259
 
["""\
260
 
+------------+-------------+---------------+
261
 
| A table    | two rows in | and row spans |
262
 
| with three +-------------+ to left and   |
263
 
| columns,   | the middle, | right.        |
264
 
+------------+-------------+---------------+
265
 
""",
266
 
"""\
267
 
<document>
268
 
    <table>
269
 
        <tgroup cols="3">
270
 
            <colspec colwidth="12">
271
 
            <colspec colwidth="13">
272
 
            <colspec colwidth="15">
273
 
            <tbody>
274
 
                <row>
275
 
                    <entry morerows="1">
276
 
                        <paragraph>
277
 
                            A table
278
 
                            with three
279
 
                            columns,
280
 
                    <entry>
281
 
                        <paragraph>
282
 
                            two rows in
283
 
                    <entry morerows="1">
284
 
                        <paragraph>
285
 
                            and row spans
286
 
                            to left and
287
 
                            right.
288
 
                <row>
289
 
                    <entry>
290
 
                        <paragraph>
291
 
                            the middle,
292
 
"""],
293
 
["""\
294
 
Complex spanning pattern (no edge knows all rows/cols):
295
 
 
296
 
+-----------+-------------------------+
297
 
| W/NW cell | N/NE cell               |
298
 
|           +-------------+-----------+
299
 
|           | Middle cell | E/SE cell |
300
 
+-----------+-------------+           |
301
 
| S/SE cell               |           |
302
 
+-------------------------+-----------+
303
 
""",
304
 
"""\
305
 
<document>
306
 
    <paragraph>
307
 
        Complex spanning pattern (no edge knows all rows/cols):
308
 
    <table>
309
 
        <tgroup cols="3">
310
 
            <colspec colwidth="11">
311
 
            <colspec colwidth="13">
312
 
            <colspec colwidth="11">
313
 
            <tbody>
314
 
                <row>
315
 
                    <entry morerows="1">
316
 
                        <paragraph>
317
 
                            W/NW cell
318
 
                    <entry morecols="1">
319
 
                        <paragraph>
320
 
                            N/NE cell
321
 
                <row>
322
 
                    <entry>
323
 
                        <paragraph>
324
 
                            Middle cell
325
 
                    <entry morerows="1">
326
 
                        <paragraph>
327
 
                            E/SE cell
328
 
                <row>
329
 
                    <entry morecols="1">
330
 
                        <paragraph>
331
 
                            S/SE cell
332
 
"""],
333
 
["""\
334
 
+------------------------+------------+----------+----------+
335
 
| Header row, column 1   | Header 2   | Header 3 | Header 4 |
336
 
+========================+============+==========+==========+
337
 
| body row 1, column 1   | column 2   | column 3 | column 4 |
338
 
+------------------------+------------+----------+----------+
339
 
| body row 2             | Cells may span columns.          |
340
 
+------------------------+------------+---------------------+
341
 
| body row 3             | Cells may  | - Table cells       |
342
 
+------------------------+ span rows. | - contain           |
343
 
| body row 4             |            | - body elements.    |
344
 
+------------------------+------------+---------------------+
345
 
""",
346
 
"""\
347
 
<document>
348
 
    <table>
349
 
        <tgroup cols="4">
350
 
            <colspec colwidth="24">
351
 
            <colspec colwidth="12">
352
 
            <colspec colwidth="10">
353
 
            <colspec colwidth="10">
354
 
            <thead>
355
 
                <row>
356
 
                    <entry>
357
 
                        <paragraph>
358
 
                            Header row, column 1
359
 
                    <entry>
360
 
                        <paragraph>
361
 
                            Header 2
362
 
                    <entry>
363
 
                        <paragraph>
364
 
                            Header 3
365
 
                    <entry>
366
 
                        <paragraph>
367
 
                            Header 4
368
 
            <tbody>
369
 
                <row>
370
 
                    <entry>
371
 
                        <paragraph>
372
 
                            body row 1, column 1
373
 
                    <entry>
374
 
                        <paragraph>
375
 
                            column 2
376
 
                    <entry>
377
 
                        <paragraph>
378
 
                            column 3
379
 
                    <entry>
380
 
                        <paragraph>
381
 
                            column 4
382
 
                <row>
383
 
                    <entry>
384
 
                        <paragraph>
385
 
                            body row 2
386
 
                    <entry morecols="2">
387
 
                        <paragraph>
388
 
                            Cells may span columns.
389
 
                <row>
390
 
                    <entry>
391
 
                        <paragraph>
392
 
                            body row 3
393
 
                    <entry morerows="1">
394
 
                        <paragraph>
395
 
                            Cells may
396
 
                            span rows.
397
 
                    <entry morecols="1" morerows="1">
398
 
                        <bullet_list bullet="-">
399
 
                            <list_item>
400
 
                                <paragraph>
401
 
                                    Table cells
402
 
                            <list_item>
403
 
                                <paragraph>
404
 
                                    contain
405
 
                            <list_item>
406
 
                                <paragraph>
407
 
                                    body elements.
408
 
                <row>
409
 
                    <entry>
410
 
                        <paragraph>
411
 
                            body row 4
412
 
"""],
413
 
["""\
414
 
+-----------------+--------+
415
 
| A simple table  | cell 2 |
416
 
+-----------------+--------+
417
 
| cell 3          | cell 4 |
418
 
+-----------------+--------+
419
 
No blank line after table.
420
 
""",
421
 
"""\
422
 
<document>
423
 
    <table>
424
 
        <tgroup cols="2">
425
 
            <colspec colwidth="17">
426
 
            <colspec colwidth="8">
427
 
            <tbody>
428
 
                <row>
429
 
                    <entry>
430
 
                        <paragraph>
431
 
                            A simple table
432
 
                    <entry>
433
 
                        <paragraph>
434
 
                            cell 2
435
 
                <row>
436
 
                    <entry>
437
 
                        <paragraph>
438
 
                            cell 3
439
 
                    <entry>
440
 
                        <paragraph>
441
 
                            cell 4
442
 
    <system_message level="2" type="WARNING">
443
 
        <paragraph>
444
 
            Blank line required after table at line 6.
445
 
    <paragraph>
446
 
        No blank line after table.
447
 
"""],
448
 
["""\
449
 
+-----------------+--------+
450
 
| A simple table  | cell 2 |
451
 
+-----------------+--------+
452
 
| cell 3          | cell 4 |
453
 
+-----------------+--------+
454
 
    Unexpected indent and no blank line after table.
455
 
""",
456
 
"""\
457
 
<document>
458
 
    <table>
459
 
        <tgroup cols="2">
460
 
            <colspec colwidth="17">
461
 
            <colspec colwidth="8">
462
 
            <tbody>
463
 
                <row>
464
 
                    <entry>
465
 
                        <paragraph>
466
 
                            A simple table
467
 
                    <entry>
468
 
                        <paragraph>
469
 
                            cell 2
470
 
                <row>
471
 
                    <entry>
472
 
                        <paragraph>
473
 
                            cell 3
474
 
                    <entry>
475
 
                        <paragraph>
476
 
                            cell 4
477
 
    <system_message level="3" type="ERROR">
478
 
        <paragraph>
479
 
            Unexpected indentation at line 6.
480
 
    <system_message level="2" type="WARNING">
481
 
        <paragraph>
482
 
            Blank line required after table at line 6.
483
 
    <block_quote>
484
 
        <paragraph>
485
 
            Unexpected indent and no blank line after table.
486
 
"""],
487
 
["""\
488
 
+--------------+-------------+
489
 
| A bad table. |             |
490
 
+--------------+             |
491
 
| Cells must be rectangles.  |
492
 
+----------------------------+
493
 
""",
494
 
"""\
495
 
<document>
496
 
    <system_message level="3" type="ERROR">
497
 
        <paragraph>
498
 
            Malformed table at line 1; formatting as a literal block.
499
 
            Malformed table; parse incomplete.
500
 
    <literal_block>
501
 
        +--------------+-------------+
502
 
        | A bad table. |             |
503
 
        +--------------+             |
504
 
        | Cells must be rectangles.  |
505
 
        +----------------------------+
506
 
"""],
507
 
["""\
508
 
+------------------------------+
509
 
| This table contains another. |
510
 
|                              |
511
 
| +-------------------------+  |
512
 
| | A table within a table. |  |
513
 
| +-------------------------+  |
514
 
+------------------------------+
515
 
""",
516
 
"""\
517
 
<document>
518
 
    <table>
519
 
        <tgroup cols="1">
520
 
            <colspec colwidth="30">
521
 
            <tbody>
522
 
                <row>
523
 
                    <entry>
524
 
                        <paragraph>
525
 
                            This table contains another.
526
 
                        <table>
527
 
                            <tgroup cols="1">
528
 
                                <colspec colwidth="25">
529
 
                                <tbody>
530
 
                                    <row>
531
 
                                        <entry>
532
 
                                            <paragraph>
533
 
                                                A table within a table.
534
 
"""],
535
 
["""\
536
 
+------------------+--------+
537
 
| A simple table   |        |
538
 
+------------------+--------+
539
 
| with empty cells |        |
540
 
+------------------+--------+
541
 
""",
542
 
"""\
543
 
<document>
544
 
    <table>
545
 
        <tgroup cols="2">
546
 
            <colspec colwidth="18">
547
 
            <colspec colwidth="8">
548
 
            <tbody>
549
 
                <row>
550
 
                    <entry>
551
 
                        <paragraph>
552
 
                            A simple table
553
 
                    <entry>
554
 
                <row>
555
 
                    <entry>
556
 
                        <paragraph>
557
 
                            with empty cells
558
 
                    <entry>
559
 
"""],
560
 
]
561
 
 
562
 
totest['simple_tables'] = [
563
 
["""\
564
 
============  ============
565
 
A table with  two columns.
566
 
============  ============
567
 
 
568
 
Paragraph.
569
 
""",
570
 
"""\
571
 
<document>
572
 
    <table>
573
 
        <tgroup cols="2">
574
 
            <colspec colwidth="12">
575
 
            <colspec colwidth="12">
576
 
            <tbody>
577
 
                <row>
578
 
                    <entry>
579
 
                        <paragraph>
580
 
                            A table with
581
 
                    <entry>
582
 
                        <paragraph>
583
 
                            two columns.
584
 
    <paragraph>
585
 
        Paragraph.
586
 
"""],
587
 
["""\
588
 
============  ============
589
 
A table with  two columns
590
 
and           two rows.
591
 
============  ============
592
 
""",
593
 
"""\
594
 
<document>
595
 
    <table>
596
 
        <tgroup cols="2">
597
 
            <colspec colwidth="12">
598
 
            <colspec colwidth="12">
599
 
            <tbody>
600
 
                <row>
601
 
                    <entry>
602
 
                        <paragraph>
603
 
                            A table with
604
 
                    <entry>
605
 
                        <paragraph>
606
 
                            two columns
607
 
                <row>
608
 
                    <entry>
609
 
                        <paragraph>
610
 
                            and
611
 
                    <entry>
612
 
                        <paragraph>
613
 
                            two rows.
614
 
"""],
615
 
["""\
616
 
============  ==============
617
 
A table with  two columns,
618
 
two rows, and a column span.
619
 
============================
620
 
""",
621
 
"""\
622
 
<document>
623
 
    <table>
624
 
        <tgroup cols="2">
625
 
            <colspec colwidth="12">
626
 
            <colspec colwidth="14">
627
 
            <tbody>
628
 
                <row>
629
 
                    <entry>
630
 
                        <paragraph>
631
 
                            A table with
632
 
                    <entry>
633
 
                        <paragraph>
634
 
                            two columns,
635
 
                <row>
636
 
                    <entry morecols="1">
637
 
                        <paragraph>
638
 
                            two rows, and a column span.
639
 
"""],
640
 
["""\
641
 
==  ===========  ===========
642
 
1   A table with three rows,
643
 
2   and three    columns.
644
 
3   First and last rows
645
 
    contain column spans.
646
 
 
647
 
    This last row is a multi-line row, and overflows to the right.
648
 
==  ========================
649
 
""",
650
 
"""\
651
 
<document>
652
 
    <table>
653
 
        <tgroup cols="3">
654
 
            <colspec colwidth="2">
655
 
            <colspec colwidth="11">
656
 
            <colspec colwidth="49">
657
 
            <tbody>
658
 
                <row>
659
 
                    <entry>
660
 
                        <paragraph>
661
 
                            1
662
 
                    <entry morecols="1">
663
 
                        <paragraph>
664
 
                            A table with three rows,
665
 
                <row>
666
 
                    <entry>
667
 
                        <paragraph>
668
 
                            2
669
 
                    <entry>
670
 
                        <paragraph>
671
 
                            and three
672
 
                    <entry>
673
 
                        <paragraph>
674
 
                            columns.
675
 
                <row>
676
 
                    <entry>
677
 
                        <paragraph>
678
 
                            3
679
 
                    <entry morecols="1">
680
 
                        <paragraph>
681
 
                            First and last rows
682
 
                            contain column spans.
683
 
                        <paragraph>
684
 
                            This last row is a multi-line row, and overflows to the right.
685
 
"""],
686
 
["""\
687
 
=======  =========  ========
688
 
A table with three  columns.
689
 
==================  ========
690
 
""",
691
 
"""\
692
 
<document>
693
 
    <table>
694
 
        <tgroup cols="3">
695
 
            <colspec colwidth="7">
696
 
            <colspec colwidth="9">
697
 
            <colspec colwidth="8">
698
 
            <tbody>
699
 
                <row>
700
 
                    <entry morecols="1">
701
 
                        <paragraph>
702
 
                            A table with three
703
 
                    <entry>
704
 
                        <paragraph>
705
 
                            columns.
706
 
"""],
707
 
["""\
708
 
==============  ======
709
 
A simple table  with
710
 
no bottom       border
711
 
""",
712
 
"""\
713
 
<document>
714
 
    <system_message level="3" type="ERROR">
715
 
        <paragraph>
716
 
            Malformed table at line 1; formatting as a literal block.
717
 
            No bottom table border found.
718
 
    <literal_block>
719
 
        ==============  ======
720
 
        A simple table  with
721
 
        no bottom       border
722
 
"""],
723
 
["""\
724
 
==============  ======
725
 
A simple table  cell 2
726
 
cell 3          cell 4
727
 
==============  ======
728
 
No blank line after table.
729
 
""",
730
 
"""\
731
 
<document>
732
 
    <system_message level="3" type="ERROR">
733
 
        <paragraph>
734
 
            Malformed table at line 1; formatting as a literal block.
735
 
            No bottom table border found or no blank line after table bottom.
736
 
    <literal_block>
737
 
        ==============  ======
738
 
        A simple table  cell 2
739
 
        cell 3          cell 4
740
 
        ==============  ======
741
 
    <system_message level="2" type="WARNING">
742
 
        <paragraph>
743
 
            Blank line required after table at line 5.
744
 
    <paragraph>
745
 
        No blank line after table.
746
 
"""],
747
 
["""\
748
 
==============  ======
749
 
A simple table  cell 2
750
 
==============  ======
751
 
cell 3          cell 4
752
 
==============  ======
753
 
No blank line after table.
754
 
""",
755
 
"""\
756
 
<document>
757
 
    <table>
758
 
        <tgroup cols="2">
759
 
            <colspec colwidth="14">
760
 
            <colspec colwidth="6">
761
 
            <thead>
762
 
                <row>
763
 
                    <entry>
764
 
                        <paragraph>
765
 
                            A simple table
766
 
                    <entry>
767
 
                        <paragraph>
768
 
                            cell 2
769
 
            <tbody>
770
 
                <row>
771
 
                    <entry>
772
 
                        <paragraph>
773
 
                            cell 3
774
 
                    <entry>
775
 
                        <paragraph>
776
 
                            cell 4
777
 
    <system_message level="2" type="WARNING">
778
 
        <paragraph>
779
 
            Blank line required after table at line 6.
780
 
    <paragraph>
781
 
        No blank line after table.
782
 
"""],
783
 
["""\
784
 
==============  ======
785
 
A simple table  cell 2
786
 
cell 3          cell 4
787
 
==============  ======
788
 
    Unexpected indent and no blank line after table.
789
 
""",
790
 
"""\
791
 
<document>
792
 
    <system_message level="3" type="ERROR">
793
 
        <paragraph>
794
 
            Malformed table at line 1; formatting as a literal block.
795
 
            No bottom table border found or no blank line after table bottom.
796
 
    <literal_block>
797
 
        ==============  ======
798
 
        A simple table  cell 2
799
 
        cell 3          cell 4
800
 
        ==============  ======
801
 
    <system_message level="2" type="WARNING">
802
 
        <paragraph>
803
 
            Blank line required after table at line 5.
804
 
    <block_quote>
805
 
        <paragraph>
806
 
            Unexpected indent and no blank line after table.
807
 
"""],
808
 
["""\
809
 
==============  ======
810
 
A bad table     cell 2
811
 
cell 3          cell 4
812
 
============  ========
813
 
""",
814
 
"""\
815
 
<document>
816
 
    <system_message level="3" type="ERROR">
817
 
        <paragraph>
818
 
            Malformed table at line 1; formatting as a literal block.
819
 
            Column span alignment problem at line offset 2.
820
 
    <literal_block>
821
 
        ==============  ======
822
 
        A bad table     cell 2
823
 
        cell 3          cell 4
824
 
        ============  ========
825
 
"""],
826
 
["""\
827
 
========  =========
828
 
A bad table  cell 2
829
 
cell 3       cell 4
830
 
========  =========
831
 
""",
832
 
"""\
833
 
<document>
834
 
    <system_message level="3" type="ERROR">
835
 
        <paragraph>
836
 
            Malformed table at line 1; formatting as a literal block.
837
 
            Text in column margin at line offset 1.
838
 
    <literal_block>
839
 
        ========  =========
840
 
        A bad table  cell 2
841
 
        cell 3       cell 4
842
 
        ========  =========
843
 
"""],
844
 
["""\
845
 
==  ============================
846
 
1   This table contains another.
847
 
2   =======  ======  ========
848
 
    A table  within  a table.
849
 
    =======  ======  ========
850
 
 
851
 
    The outer table does have to
852
 
    have at least two columns
853
 
    though.
854
 
==  ============================
855
 
""",
856
 
"""\
857
 
<document>
858
 
    <table>
859
 
        <tgroup cols="2">
860
 
            <colspec colwidth="2">
861
 
            <colspec colwidth="28">
862
 
            <tbody>
863
 
                <row>
864
 
                    <entry>
865
 
                        <paragraph>
866
 
                            1
867
 
                    <entry>
868
 
                        <paragraph>
869
 
                            This table contains another.
870
 
                <row>
871
 
                    <entry>
872
 
                        <paragraph>
873
 
                            2
874
 
                    <entry>
875
 
                        <table>
876
 
                            <tgroup cols="3">
877
 
                                <colspec colwidth="7">
878
 
                                <colspec colwidth="6">
879
 
                                <colspec colwidth="8">
880
 
                                <tbody>
881
 
                                    <row>
882
 
                                        <entry>
883
 
                                            <paragraph>
884
 
                                                A table
885
 
                                        <entry>
886
 
                                            <paragraph>
887
 
                                                within
888
 
                                        <entry>
889
 
                                            <paragraph>
890
 
                                                a table.
891
 
                        <paragraph>
892
 
                            The outer table does have to
893
 
                            have at least two columns
894
 
                            though.
895
 
"""],
896
 
["""\
897
 
================  ======
898
 
A simple table
899
 
with empty cells
900
 
================  ======
901
 
""",
902
 
"""\
903
 
<document>
904
 
    <table>
905
 
        <tgroup cols="2">
906
 
            <colspec colwidth="16">
907
 
            <colspec colwidth="6">
908
 
            <tbody>
909
 
                <row>
910
 
                    <entry>
911
 
                        <paragraph>
912
 
                            A simple table
913
 
                    <entry>
914
 
                <row>
915
 
                    <entry>
916
 
                        <paragraph>
917
 
                            with empty cells
918
 
                    <entry>
919
 
"""],
920
 
["""\
921
 
==============  ========
922
 
   A table        with
923
 
==============  ========
924
 
   centered      cells.
925
 
 
926
 
==============  ========
927
 
""",
928
 
"""\
929
 
<document>
930
 
    <table>
931
 
        <tgroup cols="2">
932
 
            <colspec colwidth="14">
933
 
            <colspec colwidth="8">
934
 
            <thead>
935
 
                <row>
936
 
                    <entry>
937
 
                        <paragraph>
938
 
                            A table
939
 
                    <entry>
940
 
                        <paragraph>
941
 
                            with
942
 
            <tbody>
943
 
                <row>
944
 
                    <entry>
945
 
                        <paragraph>
946
 
                            centered
947
 
                    <entry>
948
 
                        <paragraph>
949
 
                            cells.
950
 
"""],
951
 
]
952
 
 
953
 
 
954
 
if __name__ == '__main__':
955
 
    import unittest
956
 
    unittest.main(defaultTest='suite')