Change the default input encoding from ``None`` to "utf-8" in io.py.
[docutils.git] / docutils / test / test_parsers / test_rst / test_tables.py
blob9b976fa3dbb46649cc652285b811be241bafc22c
1 #! /usr/bin/env python3
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 import os
13 from pathlib import Path
14 import sys
15 import unittest
17 if __name__ == '__main__':
18 # prepend the "docutils root" to the Python library path
19 # so we import the local `docutils` package.
20 sys.path.insert(0, str(Path(__file__).resolve().parents[3]))
22 from docutils.frontend import get_default_settings
23 from docutils.parsers.rst import Parser
24 from docutils.utils import new_document
26 # TEST_ROOT is ./test/ from the docutils root
27 TEST_ROOT = os.path.abspath(os.path.join(__file__, '..', '..', '..'))
30 class ParserTestCase(unittest.TestCase):
31 def test_parser(self):
32 parser = Parser()
33 settings = get_default_settings(Parser)
34 settings.warning_stream = ''
35 settings.halt_level = 5
36 for name, cases in totest.items():
37 for casenum, (case_input, case_expected) in enumerate(cases):
38 with self.subTest(id=f'totest[{name!r}][{casenum}]'):
39 document = new_document('test data', settings.copy())
40 parser.parse(case_input, document)
41 output = document.pformat()
42 self.assertEqual(case_expected, output)
45 mydir = os.path.join(TEST_ROOT, 'test_parsers/test_rst')
46 include2 = os.path.join(mydir, 'test_directives/include2.txt')
48 totest = {}
50 totest['grid_tables'] = [
51 ["""\
52 +-------------------------------------+
53 | A table with one cell and one line. |
54 +-------------------------------------+
55 """,
56 """\
57 <document source="test data">
58 <table>
59 <tgroup cols="1">
60 <colspec colwidth="37">
61 <tbody>
62 <row>
63 <entry>
64 <paragraph>
65 A table with one cell and one line.
66 """],
67 ["""\
68 +-----------------------+
69 | A table with one cell |
70 | and two lines. |
71 +-----------------------+
72 """,
73 """\
74 <document source="test data">
75 <table>
76 <tgroup cols="1">
77 <colspec colwidth="23">
78 <tbody>
79 <row>
80 <entry>
81 <paragraph>
82 A table with one cell
83 and two lines.
84 """],
85 ["""\
86 +-----------------------+
87 | A malformed table. |
88 +-----------------------+
89 """,
90 """\
91 <document source="test data">
92 <system_message level="3" line="1" source="test data" type="ERROR">
93 <paragraph>
94 Malformed table.
95 <literal_block xml:space="preserve">
96 +-----------------------+
97 | A malformed table. |
98 +-----------------------+
99 """],
100 ["""\
101 +------------------------+
102 | A well-formed | table. |
103 +------------------------+
105 +------------------------+
106 | This +----------+ too! |
107 +------------------------+
108 """,
109 """\
110 <document source="test data">
111 <table>
112 <tgroup cols="1">
113 <colspec colwidth="24">
114 <tbody>
115 <row>
116 <entry>
117 <paragraph>
118 A well-formed | table.
119 <table>
120 <tgroup cols="1">
121 <colspec colwidth="24">
122 <tbody>
123 <row>
124 <entry>
125 <paragraph>
126 This +----------+ too!
127 """],
128 ["""\
129 +--------------+--------------+
130 | A table with | two columns. |
131 +--------------+--------------+
132 """,
133 """\
134 <document source="test data">
135 <table>
136 <tgroup cols="2">
137 <colspec colwidth="14">
138 <colspec colwidth="14">
139 <tbody>
140 <row>
141 <entry>
142 <paragraph>
143 A table with
144 <entry>
145 <paragraph>
146 two columns.
147 """],
148 ["""\
149 +--------------+
150 | A table with |
151 +--------------+
152 | two rows. |
153 +--------------+
154 """,
155 """\
156 <document source="test data">
157 <table>
158 <tgroup cols="1">
159 <colspec colwidth="14">
160 <tbody>
161 <row>
162 <entry>
163 <paragraph>
164 A table with
165 <row>
166 <entry>
167 <paragraph>
168 two rows.
169 """],
170 ["""\
171 +--------------+-------------+
172 | A table with | two columns |
173 +--------------+-------------+
174 | and | two rows. |
175 +--------------+-------------+
176 """,
177 """\
178 <document source="test data">
179 <table>
180 <tgroup cols="2">
181 <colspec colwidth="14">
182 <colspec colwidth="13">
183 <tbody>
184 <row>
185 <entry>
186 <paragraph>
187 A table with
188 <entry>
189 <paragraph>
190 two columns
191 <row>
192 <entry>
193 <paragraph>
195 <entry>
196 <paragraph>
197 two rows.
198 """],
199 ["""\
200 +--------------+---------------+
201 | A table with | two columns, |
202 +--------------+---------------+
203 | two rows, and a column span. |
204 +------------------------------+
205 """,
206 """\
207 <document source="test data">
208 <table>
209 <tgroup cols="2">
210 <colspec colwidth="14">
211 <colspec colwidth="15">
212 <tbody>
213 <row>
214 <entry>
215 <paragraph>
216 A table with
217 <entry>
218 <paragraph>
219 two columns,
220 <row>
221 <entry morecols="1">
222 <paragraph>
223 two rows, and a column span.
224 """],
225 ["""\
226 +--------------------------+
227 | A table with three rows, |
228 +------------+-------------+
229 | and two | columns. |
230 +------------+-------------+
231 | First and last rows |
232 | contains column spans. |
233 +--------------------------+
234 """,
235 """\
236 <document source="test data">
237 <table>
238 <tgroup cols="2">
239 <colspec colwidth="12">
240 <colspec colwidth="13">
241 <tbody>
242 <row>
243 <entry morecols="1">
244 <paragraph>
245 A table with three rows,
246 <row>
247 <entry>
248 <paragraph>
249 and two
250 <entry>
251 <paragraph>
252 columns.
253 <row>
254 <entry morecols="1">
255 <paragraph>
256 First and last rows
257 contains column spans.
258 """],
259 ["""\
260 +--------------+--------------+
261 | A table with | two columns, |
262 +--------------+ and a row |
263 | two rows, | span. |
264 +--------------+--------------+
265 """,
266 """\
267 <document source="test data">
268 <table>
269 <tgroup cols="2">
270 <colspec colwidth="14">
271 <colspec colwidth="14">
272 <tbody>
273 <row>
274 <entry>
275 <paragraph>
276 A table with
277 <entry morerows="1">
278 <paragraph>
279 two columns,
280 and a row
281 span.
282 <row>
283 <entry>
284 <paragraph>
285 two rows,
286 """],
287 ["""\
288 +------------+-------------+---------------+
289 | A table | two rows in | and row spans |
290 | with three +-------------+ to left and |
291 | columns, | the middle, | right. |
292 +------------+-------------+---------------+
293 """,
294 """\
295 <document source="test data">
296 <table>
297 <tgroup cols="3">
298 <colspec colwidth="12">
299 <colspec colwidth="13">
300 <colspec colwidth="15">
301 <tbody>
302 <row>
303 <entry morerows="1">
304 <paragraph>
305 A table
306 with three
307 columns,
308 <entry>
309 <paragraph>
310 two rows in
311 <entry morerows="1">
312 <paragraph>
313 and row spans
314 to left and
315 right.
316 <row>
317 <entry>
318 <paragraph>
319 the middle,
320 """],
321 ["""\
322 Complex spanning pattern (no edge knows all rows/cols):
324 +-----------+-------------------------+
325 | W/NW cell | N/NE cell |
326 | +-------------+-----------+
327 | | Middle cell | E/SE cell |
328 +-----------+-------------+ |
329 | S/SE cell | |
330 +-------------------------+-----------+
331 """,
332 """\
333 <document source="test data">
334 <paragraph>
335 Complex spanning pattern (no edge knows all rows/cols):
336 <table>
337 <tgroup cols="3">
338 <colspec colwidth="11">
339 <colspec colwidth="13">
340 <colspec colwidth="11">
341 <tbody>
342 <row>
343 <entry morerows="1">
344 <paragraph>
345 W/NW cell
346 <entry morecols="1">
347 <paragraph>
348 N/NE cell
349 <row>
350 <entry>
351 <paragraph>
352 Middle cell
353 <entry morerows="1">
354 <paragraph>
355 E/SE cell
356 <row>
357 <entry morecols="1">
358 <paragraph>
359 S/SE cell
360 """],
361 ["""\
362 +------------------------+------------+----------+----------+
363 | Header row, column 1 | Header 2 | Header 3 | Header 4 |
364 +========================+============+==========+==========+
365 | body row 1, column 1 | column 2 | column 3 | column 4 |
366 +------------------------+------------+----------+----------+
367 | body row 2 | Cells may span columns. |
368 +------------------------+------------+---------------------+
369 | body row 3 | Cells may | - Table cells |
370 +------------------------+ span rows. | - contain |
371 | body row 4 | | - body elements. |
372 +------------------------+------------+---------------------+
373 """,
374 """\
375 <document source="test data">
376 <table>
377 <tgroup cols="4">
378 <colspec colwidth="24">
379 <colspec colwidth="12">
380 <colspec colwidth="10">
381 <colspec colwidth="10">
382 <thead>
383 <row>
384 <entry>
385 <paragraph>
386 Header row, column 1
387 <entry>
388 <paragraph>
389 Header 2
390 <entry>
391 <paragraph>
392 Header 3
393 <entry>
394 <paragraph>
395 Header 4
396 <tbody>
397 <row>
398 <entry>
399 <paragraph>
400 body row 1, column 1
401 <entry>
402 <paragraph>
403 column 2
404 <entry>
405 <paragraph>
406 column 3
407 <entry>
408 <paragraph>
409 column 4
410 <row>
411 <entry>
412 <paragraph>
413 body row 2
414 <entry morecols="2">
415 <paragraph>
416 Cells may span columns.
417 <row>
418 <entry>
419 <paragraph>
420 body row 3
421 <entry morerows="1">
422 <paragraph>
423 Cells may
424 span rows.
425 <entry morecols="1" morerows="1">
426 <bullet_list bullet="-">
427 <list_item>
428 <paragraph>
429 Table cells
430 <list_item>
431 <paragraph>
432 contain
433 <list_item>
434 <paragraph>
435 body elements.
436 <row>
437 <entry>
438 <paragraph>
439 body row 4
440 """],
441 ["""\
442 +-----------------+--------+
443 | A simple table | cell 2 |
444 +-----------------+--------+
445 | cell 3 | cell 4 |
446 +-----------------+--------+
447 No blank line after table.
448 """,
449 """\
450 <document source="test data">
451 <table>
452 <tgroup cols="2">
453 <colspec colwidth="17">
454 <colspec colwidth="8">
455 <tbody>
456 <row>
457 <entry>
458 <paragraph>
459 A simple table
460 <entry>
461 <paragraph>
462 cell 2
463 <row>
464 <entry>
465 <paragraph>
466 cell 3
467 <entry>
468 <paragraph>
469 cell 4
470 <system_message level="2" line="6" source="test data" type="WARNING">
471 <paragraph>
472 Blank line required after table.
473 <paragraph>
474 No blank line after table.
475 """],
476 ["""\
477 +-----------------+--------+
478 | A simple table | cell 2 |
479 +-----------------+--------+
480 | cell 3 | cell 4 |
481 +-----------------+--------+
482 Unexpected indent and no blank line after table.
483 """,
484 """\
485 <document source="test data">
486 <table>
487 <tgroup cols="2">
488 <colspec colwidth="17">
489 <colspec colwidth="8">
490 <tbody>
491 <row>
492 <entry>
493 <paragraph>
494 A simple table
495 <entry>
496 <paragraph>
497 cell 2
498 <row>
499 <entry>
500 <paragraph>
501 cell 3
502 <entry>
503 <paragraph>
504 cell 4
505 <system_message level="3" line="6" source="test data" type="ERROR">
506 <paragraph>
507 Unexpected indentation.
508 <system_message level="2" line="6" source="test data" type="WARNING">
509 <paragraph>
510 Blank line required after table.
511 <block_quote>
512 <paragraph>
513 Unexpected indent and no blank line after table.
514 """],
515 ["""\
516 +--------------+-------------+
517 | A bad table. | |
518 +--------------+ |
519 | Cells must be rectangles. |
520 +----------------------------+
521 """,
522 """\
523 <document source="test data">
524 <system_message level="3" line="1" source="test data" type="ERROR">
525 <paragraph>
526 Malformed table.
527 Malformed table; parse incomplete.
528 <literal_block xml:space="preserve">
529 +--------------+-------------+
530 | A bad table. | |
531 +--------------+ |
532 | Cells must be rectangles. |
533 +----------------------------+
534 """],
535 ["""\
536 +------------------------------+
537 | This table contains another. |
539 | +-------------------------+ |
540 | | A table within a table. | |
541 | +-------------------------+ |
542 +------------------------------+
543 """,
544 """\
545 <document source="test data">
546 <table>
547 <tgroup cols="1">
548 <colspec colwidth="30">
549 <tbody>
550 <row>
551 <entry>
552 <paragraph>
553 This table contains another.
554 <table>
555 <tgroup cols="1">
556 <colspec colwidth="25">
557 <tbody>
558 <row>
559 <entry>
560 <paragraph>
561 A table within a table.
562 """],
563 ["""\
564 +------------------+--------+
565 | A simple table | |
566 +------------------+--------+
567 | with empty cells | |
568 +------------------+--------+
569 """,
570 """\
571 <document source="test data">
572 <table>
573 <tgroup cols="2">
574 <colspec colwidth="18">
575 <colspec colwidth="8">
576 <tbody>
577 <row>
578 <entry>
579 <paragraph>
580 A simple table
581 <entry>
582 <row>
583 <entry>
584 <paragraph>
585 with empty cells
586 <entry>
587 """],
588 [("""\
589 +------------------------------------------------------------------------------+
590 | .. include:: |
592 +------------------------------------------------------------------------------+
593 | (The first cell of this table may expand |
594 | to accommodate long filesystem paths.) |
595 +------------------------------------------------------------------------------+
596 """) % ('\n'.join('| %-70s |' % include2[part * 70 : (part + 1) * 70] # noqa: E203
597 for part in range(len(include2) // 70 + 1))),
598 """\
599 <document source="test data">
600 <table>
601 <tgroup cols="1">
602 <colspec colwidth="78">
603 <tbody>
604 <row>
605 <entry>
606 <paragraph>
607 Here are some paragraphs
608 that can appear at any level.
609 <paragraph>
610 This file (include2.txt) is used by
611 <literal>
612 test_include.py
614 <row>
615 <entry>
616 <paragraph>
617 (The first cell of this table may expand
618 to accommodate long filesystem paths.)
619 """],
620 [("""\
621 Something before.
623 +------------------------------------------------------------------------------+
624 | .. include:: |
626 +------------------------------------------------------------------------------+
628 Something afterwards.
630 And more.
631 """) % ('\n'.join('| %-70s |' % include2[part * 70 : (part + 1) * 70] # noqa: E203
632 for part in range(len(include2) // 70 + 1))),
633 """\
634 <document source="test data">
635 <paragraph>
636 Something before.
637 <table>
638 <tgroup cols="1">
639 <colspec colwidth="78">
640 <tbody>
641 <row>
642 <entry>
643 <paragraph>
644 Here are some paragraphs
645 that can appear at any level.
646 <paragraph>
647 This file (include2.txt) is used by
648 <literal>
649 test_include.py
651 <paragraph>
652 Something afterwards.
653 <paragraph>
654 And more.
655 """],
658 totest['simple_tables'] = [
659 ["""\
660 ============ ============
661 A table with two columns.
662 ============ ============
664 Paragraph.
665 """,
666 """\
667 <document source="test data">
668 <table>
669 <tgroup cols="2">
670 <colspec colwidth="12">
671 <colspec colwidth="12">
672 <tbody>
673 <row>
674 <entry>
675 <paragraph>
676 A table with
677 <entry>
678 <paragraph>
679 two columns.
680 <paragraph>
681 Paragraph.
682 """],
683 ["""\
684 ============ ============
685 A table with two columns
686 and two rows.
687 ============ ============
688 """,
689 """\
690 <document source="test data">
691 <table>
692 <tgroup cols="2">
693 <colspec colwidth="12">
694 <colspec colwidth="12">
695 <tbody>
696 <row>
697 <entry>
698 <paragraph>
699 A table with
700 <entry>
701 <paragraph>
702 two columns
703 <row>
704 <entry>
705 <paragraph>
707 <entry>
708 <paragraph>
709 two rows.
710 """],
711 ["""\
712 ============ ==============
713 A table with two columns,
714 two rows, and a column span.
715 ============================
716 """,
717 """\
718 <document source="test data">
719 <table>
720 <tgroup cols="2">
721 <colspec colwidth="12">
722 <colspec colwidth="14">
723 <tbody>
724 <row>
725 <entry>
726 <paragraph>
727 A table with
728 <entry>
729 <paragraph>
730 two columns,
731 <row>
732 <entry morecols="1">
733 <paragraph>
734 two rows, and a column span.
735 """],
736 ["""\
737 == =========== ===========
738 1 A table with three rows,
739 -- ------------------------
740 2 and three columns.
741 3 First and third rows
742 contain column spans.
744 This row is a multi-line row, and overflows to the right.
745 -- ------------------------
746 4 One last row.
747 == =========== ===========
748 """,
749 """\
750 <document source="test data">
751 <table>
752 <tgroup cols="3">
753 <colspec colwidth="2">
754 <colspec colwidth="11">
755 <colspec colwidth="44">
756 <tbody>
757 <row>
758 <entry>
759 <paragraph>
761 <entry morecols="1">
762 <paragraph>
763 A table with three rows,
764 <row>
765 <entry>
766 <paragraph>
768 <entry>
769 <paragraph>
770 and three
771 <entry>
772 <paragraph>
773 columns.
774 <row>
775 <entry>
776 <paragraph>
778 <entry morecols="1">
779 <paragraph>
780 First and third rows
781 contain column spans.
782 <paragraph>
783 This row is a multi-line row, and overflows to the right.
784 <row>
785 <entry>
786 <paragraph>
788 <entry>
789 <paragraph>
790 One last
791 <entry>
792 <paragraph>
793 row.
794 """],
795 ["""\
796 ======= ========= ========
797 A table with three columns.
798 ================== ========
799 """,
800 """\
801 <document source="test data">
802 <table>
803 <tgroup cols="3">
804 <colspec colwidth="7">
805 <colspec colwidth="9">
806 <colspec colwidth="8">
807 <tbody>
808 <row>
809 <entry morecols="1">
810 <paragraph>
811 A table with three
812 <entry>
813 <paragraph>
814 columns.
815 """],
816 ["""\
817 ============== ======
818 A simple table this text extends to the right
819 cell 3 as does this text
820 ============== ======
821 """,
822 """\
823 <document source="test data">
824 <table>
825 <tgroup cols="2">
826 <colspec colwidth="14">
827 <colspec colwidth="30">
828 <tbody>
829 <row>
830 <entry>
831 <paragraph>
832 A simple table
833 <entry>
834 <paragraph>
835 this text extends to the right
836 <row>
837 <entry>
838 <paragraph>
839 cell 3
840 <entry>
841 <paragraph>
842 as does this text
843 """],
844 ["""\
845 ============== ======
846 A simple table this text extends to the right
847 continuation of cell 2
848 ============== ======
849 """,
850 """\
851 <document source="test data">
852 <table>
853 <tgroup cols="2">
854 <colspec colwidth="14">
855 <colspec colwidth="30">
856 <tbody>
857 <row>
858 <entry>
859 <paragraph>
860 A simple table
861 <entry>
862 <paragraph>
863 this text extends to the right
864 continuation of cell 2
865 """],
866 ["""\
867 ============== ======
868 A simple table with
869 no bottom border
870 """,
871 """\
872 <document source="test data">
873 <system_message level="3" line="1" source="test data" type="ERROR">
874 <paragraph>
875 Malformed table.
876 No bottom table border found.
877 <literal_block xml:space="preserve">
878 ============== ======
879 A simple table with
880 no bottom border
881 """],
882 ["""\
883 ============== ======
884 A simple table cell 2
885 cell 3 cell 4
886 ============== ======
887 No blank line after table.
888 """,
889 """\
890 <document source="test data">
891 <system_message level="3" line="1" source="test data" type="ERROR">
892 <paragraph>
893 Malformed table.
894 No bottom table border found or no blank line after table bottom.
895 <literal_block xml:space="preserve">
896 ============== ======
897 A simple table cell 2
898 cell 3 cell 4
899 ============== ======
900 <system_message level="2" line="5" source="test data" type="WARNING">
901 <paragraph>
902 Blank line required after table.
903 <paragraph>
904 No blank line after table.
905 """],
906 ["""\
907 ============== ======
908 A simple table cell 2
909 ============== ======
910 cell 3 cell 4
911 ============== ======
912 No blank line after table.
913 """,
914 """\
915 <document source="test data">
916 <table>
917 <tgroup cols="2">
918 <colspec colwidth="14">
919 <colspec colwidth="6">
920 <thead>
921 <row>
922 <entry>
923 <paragraph>
924 A simple table
925 <entry>
926 <paragraph>
927 cell 2
928 <tbody>
929 <row>
930 <entry>
931 <paragraph>
932 cell 3
933 <entry>
934 <paragraph>
935 cell 4
936 <system_message level="2" line="6" source="test data" type="WARNING">
937 <paragraph>
938 Blank line required after table.
939 <paragraph>
940 No blank line after table.
941 """],
942 ["""\
943 ============== ======
944 A simple table cell 2
945 cell 3 cell 4
946 ============== ======
947 Unexpected indent and no blank line after table.
948 """,
949 """\
950 <document source="test data">
951 <system_message level="3" line="1" source="test data" type="ERROR">
952 <paragraph>
953 Malformed table.
954 No bottom table border found or no blank line after table bottom.
955 <literal_block xml:space="preserve">
956 ============== ======
957 A simple table cell 2
958 cell 3 cell 4
959 ============== ======
960 <system_message level="2" line="5" source="test data" type="WARNING">
961 <paragraph>
962 Blank line required after table.
963 <block_quote>
964 <paragraph>
965 Unexpected indent and no blank line after table.
966 """],
967 ["""\
968 ============== ======
969 A bad table cell 2
970 cell 3 cell 4
971 ============ ========
972 """,
973 """\
974 <document source="test data">
975 <system_message level="3" line="4" source="test data" type="ERROR">
976 <paragraph>
977 Malformed table.
978 Column span alignment problem in table line 4.
979 <literal_block xml:space="preserve">
980 ============== ======
981 A bad table cell 2
982 cell 3 cell 4
983 ============ ========
984 """],
985 ["""\
986 ======== =========
987 A bad table cell 2
988 cell 3 cell 4
989 ======== =========
990 """,
991 """\
992 <document source="test data">
993 <system_message level="3" line="2" source="test data" type="ERROR">
994 <paragraph>
995 Malformed table.
996 Text in column margin in table line 2.
997 <literal_block xml:space="preserve">
998 ======== =========
999 A bad table cell 2
1000 cell 3 cell 4
1001 ======== =========
1002 """],
1003 ["""\
1004 == ============================
1005 1 This table contains another.
1006 2 ======= ====== ========
1007 A table within a table.
1008 ======= ====== ========
1010 The outer table does have to
1011 have at least two columns
1012 though.
1013 == ============================
1014 """,
1015 """\
1016 <document source="test data">
1017 <table>
1018 <tgroup cols="2">
1019 <colspec colwidth="2">
1020 <colspec colwidth="28">
1021 <tbody>
1022 <row>
1023 <entry>
1024 <paragraph>
1026 <entry>
1027 <paragraph>
1028 This table contains another.
1029 <row>
1030 <entry>
1031 <paragraph>
1033 <entry>
1034 <table>
1035 <tgroup cols="3">
1036 <colspec colwidth="7">
1037 <colspec colwidth="6">
1038 <colspec colwidth="8">
1039 <tbody>
1040 <row>
1041 <entry>
1042 <paragraph>
1043 A table
1044 <entry>
1045 <paragraph>
1046 within
1047 <entry>
1048 <paragraph>
1049 a table.
1050 <paragraph>
1051 The outer table does have to
1052 have at least two columns
1053 though.
1054 """],
1055 ["""\
1056 ================ ======
1057 A simple table
1058 with empty cells
1059 ================ ======
1060 """,
1061 """\
1062 <document source="test data">
1063 <table>
1064 <tgroup cols="2">
1065 <colspec colwidth="16">
1066 <colspec colwidth="6">
1067 <tbody>
1068 <row>
1069 <entry>
1070 <paragraph>
1071 A simple table
1072 <entry>
1073 <row>
1074 <entry>
1075 <paragraph>
1076 with empty cells
1077 <entry>
1078 """],
1079 ["""\
1080 ============== ========
1081 A table with
1082 ============== ========
1083 centered cells.
1085 ============== ========
1086 """,
1087 """\
1088 <document source="test data">
1089 <table>
1090 <tgroup cols="2">
1091 <colspec colwidth="14">
1092 <colspec colwidth="8">
1093 <thead>
1094 <row>
1095 <entry>
1096 <paragraph>
1097 A table
1098 <entry>
1099 <paragraph>
1100 with
1101 <tbody>
1102 <row>
1103 <entry>
1104 <paragraph>
1105 centered
1106 <entry>
1107 <paragraph>
1108 cells.
1109 """],
1110 ["""\
1111 ============== ======
1112 A simple table this text extends to the right
1113 cell 3 the bottom border below is too long
1114 ============== ========
1115 """,
1116 """\
1117 <document source="test data">
1118 <system_message level="3" line="1" source="test data" type="ERROR">
1119 <paragraph>
1120 Malformed table.
1121 Bottom/header table border does not match top border.
1122 <literal_block xml:space="preserve">
1123 ============== ======
1124 A simple table this text extends to the right
1125 cell 3 the bottom border below is too long
1126 ============== ========
1127 """],
1128 ["""\
1129 ============ =================
1130 A table with row separators.
1131 ------------ -----------------
1133 Blank line before.
1134 ------------ -----------------
1136 Blank lines before and after.
1138 ------------ -----------------
1139 Blank line after.
1141 ============ =================
1142 """,
1143 """\
1144 <document source="test data">
1145 <table>
1146 <tgroup cols="2">
1147 <colspec colwidth="12">
1148 <colspec colwidth="17">
1149 <tbody>
1150 <row>
1151 <entry>
1152 <paragraph>
1153 A table with
1154 <entry>
1155 <paragraph>
1156 row separators.
1157 <row>
1158 <entry>
1159 <paragraph>
1160 Blank line
1161 <entry>
1162 <paragraph>
1163 before.
1164 <row>
1165 <entry>
1166 <paragraph>
1167 Blank lines
1168 <entry>
1169 <paragraph>
1170 before and after.
1171 <row>
1172 <entry>
1173 <paragraph>
1174 Blank line
1175 <entry>
1176 <paragraph>
1177 after.
1178 """],
1179 ["""\
1180 ============ ====================
1181 A table with many row separators.
1182 ------------ --------------------
1183 ------------ --------------------
1185 ------------ --------------------
1186 ============ ====================
1187 """,
1188 """\
1189 <document source="test data">
1190 <table>
1191 <tgroup cols="2">
1192 <colspec colwidth="12">
1193 <colspec colwidth="20">
1194 <tbody>
1195 <row>
1196 <entry>
1197 <paragraph>
1198 A table with
1199 <entry>
1200 <paragraph>
1201 many row separators.
1202 <row>
1203 <entry>
1204 <entry>
1205 <row>
1206 <entry>
1207 <entry>
1208 <row>
1209 <entry>
1210 <entry>
1211 """],
1212 ["""\
1213 == =========== ===========
1214 1 Span columns 2 & 3
1215 -- ------------------------
1216 2 Span columns 2 & 3
1217 ------------------------
1219 == =========== ===========
1221 == =========== ===========
1222 1 Span cols 1&2 but not 3
1223 --------------- -----------
1224 2 Span cols 1&2 but not 3
1225 ---------------
1226 3 no spans here
1227 == =========== ===========
1229 == =========== ===========
1230 1 Not a span Not a span
1231 ----------- -----------
1233 == =========== ===========
1234 """,
1235 """\
1236 <document source="test data">
1237 <system_message level="3" line="4" source="test data" type="ERROR">
1238 <paragraph>
1239 Malformed table.
1240 Text in column margin in table line 4.
1241 <literal_block xml:space="preserve">
1242 == =========== ===========
1243 1 Span columns 2 & 3
1244 -- ------------------------
1245 2 Span columns 2 & 3
1246 ------------------------
1248 == =========== ===========
1249 <system_message level="3" line="13" source="test data" type="ERROR">
1250 <paragraph>
1251 Malformed table.
1252 Column span incomplete in table line 5.
1253 <literal_block xml:space="preserve">
1254 == =========== ===========
1255 1 Span cols 1&2 but not 3
1256 --------------- -----------
1257 2 Span cols 1&2 but not 3
1258 ---------------
1259 3 no spans here
1260 == =========== ===========
1261 <table>
1262 <tgroup cols="3">
1263 <colspec colwidth="2">
1264 <colspec colwidth="11">
1265 <colspec colwidth="11">
1266 <tbody>
1267 <row>
1268 <entry>
1269 <paragraph>
1271 <entry>
1272 <system_message level="4" line="19" source="test data" type="SEVERE">
1273 <paragraph>
1274 Unexpected section title.
1275 <literal_block xml:space="preserve">
1276 Not a span
1277 -----------
1278 <entry>
1279 <system_message level="4" line="19" source="test data" type="SEVERE">
1280 <paragraph>
1281 Unexpected section title.
1282 <literal_block xml:space="preserve">
1283 Not a span
1284 -----------
1285 <row>
1286 <entry>
1287 <paragraph>
1289 <entry>
1290 <entry>
1291 """],
1292 ["""\
1293 ========= =====================================================================
1294 Inclusion .. include::
1296 Note The first row of this table may expand
1297 to accommodate long filesystem paths.
1298 ========= =====================================================================
1299 """ % ('\n'.join(' %-65s' % include2[part * 65 : (part + 1) * 65] # noqa: E203
1300 for part in range(len(include2) // 65 + 1))),
1301 """\
1302 <document source="test data">
1303 <table>
1304 <tgroup cols="2">
1305 <colspec colwidth="9">
1306 <colspec colwidth="69">
1307 <tbody>
1308 <row>
1309 <entry>
1310 <paragraph>
1311 Inclusion
1312 <entry>
1313 <paragraph>
1314 Here are some paragraphs
1315 that can appear at any level.
1316 <paragraph>
1317 This file (include2.txt) is used by
1318 <literal>
1319 test_include.py
1321 <row>
1322 <entry>
1323 <paragraph>
1324 Note
1325 <entry>
1326 <paragraph>
1327 The first row of this table may expand
1328 to accommodate long filesystem paths.
1329 """],
1333 if __name__ == '__main__':
1334 unittest.main()