4 # Author: David Goodger <goodger@python.org>
5 # Copyright: This module has been placed in the public domain.
12 from __init__
import DocutilsTestSupport
15 s
= DocutilsTestSupport
.ParserTestSuite()
16 s
.generateTests(totest
)
19 mydir
= 'test_parsers/test_rst/'
20 include2
= os
.path
.join(mydir
, 'test_directives/include2.txt')
24 totest
['grid_tables'] = [
26 +-------------------------------------+
27 | A table with one cell and one line. |
28 +-------------------------------------+
31 <document source="test data">
34 <colspec colwidth="37">
39 A table with one cell and one line.
42 +-----------------------+
43 | A table with one cell |
45 +-----------------------+
48 <document source="test data">
51 <colspec colwidth="23">
60 +-----------------------+
61 | A malformed table. |
62 +-----------------------+
65 <document source="test data">
66 <system_message level="3" line="1" source="test data" type="ERROR">
69 <literal_block xml:space="preserve">
70 +-----------------------+
71 | A malformed table. |
72 +-----------------------+
75 +------------------------+
76 | A well-formed | table. |
77 +------------------------+
79 +------------------------+
80 | This +----------+ too! |
81 +------------------------+
84 <document source="test data">
87 <colspec colwidth="24">
92 A well-formed | table.
95 <colspec colwidth="24">
100 This +----------+ too!
103 +--------------+--------------+
104 | A table with | two columns. |
105 +--------------+--------------+
108 <document source="test data">
111 <colspec colwidth="14">
112 <colspec colwidth="14">
130 <document source="test data">
133 <colspec colwidth="14">
145 +--------------+-------------+
146 | A table with | two columns |
147 +--------------+-------------+
149 +--------------+-------------+
152 <document source="test data">
155 <colspec colwidth="14">
156 <colspec colwidth="13">
174 +--------------+---------------+
175 | A table with | two columns, |
176 +--------------+---------------+
177 | two rows, and a column span. |
178 +------------------------------+
181 <document source="test data">
184 <colspec colwidth="14">
185 <colspec colwidth="15">
197 two rows, and a column span.
200 +--------------------------+
201 | A table with three rows, |
202 +------------+-------------+
203 | and two | columns. |
204 +------------+-------------+
205 | First and last rows |
206 | contains column spans. |
207 +--------------------------+
210 <document source="test data">
213 <colspec colwidth="12">
214 <colspec colwidth="13">
219 A table with three rows,
231 contains column spans.
234 +--------------+--------------+
235 | A table with | two columns, |
236 +--------------+ and a row |
237 | two rows, | span. |
238 +--------------+--------------+
241 <document source="test data">
244 <colspec colwidth="14">
245 <colspec colwidth="14">
262 +------------+-------------+---------------+
263 | A table | two rows in | and row spans |
264 | with three +-------------+ to left and |
265 | columns, | the middle, | right. |
266 +------------+-------------+---------------+
269 <document source="test data">
272 <colspec colwidth="12">
273 <colspec colwidth="13">
274 <colspec colwidth="15">
296 Complex spanning pattern (no edge knows all rows/cols):
298 +-----------+-------------------------+
299 | W/NW cell | N/NE cell |
300 | +-------------+-----------+
301 | | Middle cell | E/SE cell |
302 +-----------+-------------+ |
304 +-------------------------+-----------+
307 <document source="test data">
309 Complex spanning pattern (no edge knows all rows/cols):
312 <colspec colwidth="11">
313 <colspec colwidth="13">
314 <colspec colwidth="11">
336 +------------------------+------------+----------+----------+
337 | Header row, column 1 | Header 2 | Header 3 | Header 4 |
338 +========================+============+==========+==========+
339 | body row 1, column 1 | column 2 | column 3 | column 4 |
340 +------------------------+------------+----------+----------+
341 | body row 2 | Cells may span columns. |
342 +------------------------+------------+---------------------+
343 | body row 3 | Cells may | - Table cells |
344 +------------------------+ span rows. | - contain |
345 | body row 4 | | - body elements. |
346 +------------------------+------------+---------------------+
349 <document source="test data">
352 <colspec colwidth="24">
353 <colspec colwidth="12">
354 <colspec colwidth="10">
355 <colspec colwidth="10">
390 Cells may span columns.
399 <entry morecols="1" morerows="1">
400 <bullet_list bullet="-">
416 +-----------------+--------+
417 | A simple table | cell 2 |
418 +-----------------+--------+
420 +-----------------+--------+
421 No blank line after table.
424 <document source="test data">
427 <colspec colwidth="17">
428 <colspec colwidth="8">
444 <system_message level="2" line="6" source="test data" type="WARNING">
446 Blank line required after table.
448 No blank line after table.
451 +-----------------+--------+
452 | A simple table | cell 2 |
453 +-----------------+--------+
455 +-----------------+--------+
456 Unexpected indent and no blank line after table.
459 <document source="test data">
462 <colspec colwidth="17">
463 <colspec colwidth="8">
479 <system_message level="3" line="6" source="test data" type="ERROR">
481 Unexpected indentation.
482 <system_message level="2" line="6" source="test data" type="WARNING">
484 Blank line required after table.
487 Unexpected indent and no blank line after table.
490 +--------------+-------------+
493 | Cells must be rectangles. |
494 +----------------------------+
497 <document source="test data">
498 <system_message level="3" line="1" source="test data" type="ERROR">
501 Malformed table; parse incomplete.
502 <literal_block xml:space="preserve">
503 +--------------+-------------+
506 | Cells must be rectangles. |
507 +----------------------------+
510 +------------------------------+
511 | This table contains another. |
513 | +-------------------------+ |
514 | | A table within a table. | |
515 | +-------------------------+ |
516 +------------------------------+
519 <document source="test data">
522 <colspec colwidth="30">
527 This table contains another.
530 <colspec colwidth="25">
535 A table within a table.
538 +------------------+--------+
540 +------------------+--------+
541 | with empty cells | |
542 +------------------+--------+
545 <document source="test data">
548 <colspec colwidth="18">
549 <colspec colwidth="8">
563 +------------------------------------------------------------------------------+
566 +------------------------------------------------------------------------------+
567 | (The first cell of this table may expand |
568 | to accommodate long filesystem paths.) |
569 +------------------------------------------------------------------------------+
570 """) % ('\n'.join(['| %-70s |' % include2
[part
* 70 : (part
+ 1) * 70]
571 for part
in range(len(include2
) // 70 + 1)])),
573 <document source="test data">
576 <colspec colwidth="78">
581 Here are some paragraphs
582 that can appear at any level.
584 This file (include2.txt) is used by
591 (The first cell of this table may expand
592 to accommodate long filesystem paths.)
597 +------------------------------------------------------------------------------+
600 +------------------------------------------------------------------------------+
602 Something afterwards.
605 """) % ('\n'.join(['| %-70s |' % include2
[part
* 70 : (part
+ 1) * 70]
606 for part
in range(len(include2
) // 70 + 1)])),
608 <document source="test data">
613 <colspec colwidth="78">
618 Here are some paragraphs
619 that can appear at any level.
621 This file (include2.txt) is used by
626 Something afterwards.
632 totest
['simple_tables'] = [
634 ============ ============
635 A table with two columns.
636 ============ ============
641 <document source="test data">
644 <colspec colwidth="12">
645 <colspec colwidth="12">
658 ============ ============
659 A table with two columns
661 ============ ============
664 <document source="test data">
667 <colspec colwidth="12">
668 <colspec colwidth="12">
686 ============ ==============
687 A table with two columns,
688 two rows, and a column span.
689 ============================
692 <document source="test data">
695 <colspec colwidth="12">
696 <colspec colwidth="14">
708 two rows, and a column span.
711 == =========== ===========
712 1 A table with three rows,
713 -- ------------------------
715 3 First and third rows
716 contain column spans.
718 This row is a multi-line row, and overflows to the right.
719 -- ------------------------
721 == =========== ===========
724 <document source="test data">
727 <colspec colwidth="2">
728 <colspec colwidth="11">
729 <colspec colwidth="44">
737 A table with three rows,
755 contain column spans.
757 This row is a multi-line row, and overflows to the right.
770 ======= ========= ========
771 A table with three columns.
772 ================== ========
775 <document source="test data">
778 <colspec colwidth="7">
779 <colspec colwidth="9">
780 <colspec colwidth="8">
791 ============== ======
796 <document source="test data">
797 <system_message level="3" line="1" source="test data" type="ERROR">
800 No bottom table border found.
801 <literal_block xml:space="preserve">
802 ============== ======
807 ============== ======
808 A simple table cell 2
810 ============== ======
811 No blank line after table.
814 <document source="test data">
815 <system_message level="3" line="1" source="test data" type="ERROR">
818 No bottom table border found or no blank line after table bottom.
819 <literal_block xml:space="preserve">
820 ============== ======
821 A simple table cell 2
823 ============== ======
824 <system_message level="2" line="5" source="test data" type="WARNING">
826 Blank line required after table.
828 No blank line after table.
831 ============== ======
832 A simple table cell 2
833 ============== ======
835 ============== ======
836 No blank line after table.
839 <document source="test data">
842 <colspec colwidth="14">
843 <colspec colwidth="6">
860 <system_message level="2" line="6" source="test data" type="WARNING">
862 Blank line required after table.
864 No blank line after table.
867 ============== ======
868 A simple table cell 2
870 ============== ======
871 Unexpected indent and no blank line after table.
874 <document source="test data">
875 <system_message level="3" line="1" source="test data" type="ERROR">
878 No bottom table border found or no blank line after table bottom.
879 <literal_block xml:space="preserve">
880 ============== ======
881 A simple table cell 2
883 ============== ======
884 <system_message level="2" line="5" source="test data" type="WARNING">
886 Blank line required after table.
889 Unexpected indent and no blank line after table.
892 ============== ======
895 ============ ========
898 <document source="test data">
899 <system_message level="3" line="4" source="test data" type="ERROR">
902 Column span alignment problem in table line 4.
903 <literal_block xml:space="preserve">
904 ============== ======
907 ============ ========
916 <document source="test data">
917 <system_message level="3" line="2" source="test data" type="ERROR">
920 Text in column margin in table line 2.
921 <literal_block xml:space="preserve">
928 == ============================
929 1 This table contains another.
930 2 ======= ====== ========
931 A table within a table.
932 ======= ====== ========
934 The outer table does have to
935 have at least two columns
937 == ============================
940 <document source="test data">
943 <colspec colwidth="2">
944 <colspec colwidth="28">
952 This table contains another.
960 <colspec colwidth="7">
961 <colspec colwidth="6">
962 <colspec colwidth="8">
975 The outer table does have to
976 have at least two columns
980 ================ ======
983 ================ ======
986 <document source="test data">
989 <colspec colwidth="16">
990 <colspec colwidth="6">
1004 ============== ========
1006 ============== ========
1009 ============== ========
1012 <document source="test data">
1015 <colspec colwidth="14">
1016 <colspec colwidth="8">
1035 ============== ======
1036 A simple table this text extends to the right
1037 cell 3 the bottom border below is too long
1038 ============== ========
1041 <document source="test data">
1042 <system_message level="3" line="1" source="test data" type="ERROR">
1045 Bottom/header table border does not match top border.
1046 <literal_block xml:space="preserve">
1047 ============== ======
1048 A simple table this text extends to the right
1049 cell 3 the bottom border below is too long
1050 ============== ========
1053 ============ =================
1054 A table with row separators.
1055 ------------ -----------------
1058 ------------ -----------------
1060 Blank lines before and after.
1062 ------------ -----------------
1065 ============ =================
1068 <document source="test data">
1071 <colspec colwidth="12">
1072 <colspec colwidth="17">
1104 ============ ====================
1105 A table with many row separators.
1106 ------------ --------------------
1107 ------------ --------------------
1109 ------------ --------------------
1110 ============ ====================
1113 <document source="test data">
1116 <colspec colwidth="12">
1117 <colspec colwidth="20">
1125 many row separators.
1137 == =========== ===========
1138 1 Span columns 2 & 3
1139 -- ------------------------
1140 2 Span columns 2 & 3
1141 ------------------------
1143 == =========== ===========
1145 == =========== ===========
1146 1 Span cols 1&2 but not 3
1147 --------------- -----------
1148 2 Span cols 1&2 but not 3
1151 == =========== ===========
1153 == =========== ===========
1154 1 Not a span Not a span
1155 ----------- -----------
1157 == =========== ===========
1160 <document source="test data">
1161 <system_message level="3" line="4" source="test data" type="ERROR">
1164 Text in column margin in table line 4.
1165 <literal_block xml:space="preserve">
1166 == =========== ===========
1167 1 Span columns 2 & 3
1168 -- ------------------------
1169 2 Span columns 2 & 3
1170 ------------------------
1172 == =========== ===========
1173 <system_message level="3" line="13" source="test data" type="ERROR">
1176 Column span incomplete in table line 5.
1177 <literal_block xml:space="preserve">
1178 == =========== ===========
1179 1 Span cols 1&2 but not 3
1180 --------------- -----------
1181 2 Span cols 1&2 but not 3
1184 == =========== ===========
1187 <colspec colwidth="2">
1188 <colspec colwidth="11">
1189 <colspec colwidth="11">
1196 <system_message level="4" line="19" source="test data" type="SEVERE">
1198 Unexpected section title.
1199 <literal_block xml:space="preserve">
1203 <system_message level="4" line="19" source="test data" type="SEVERE">
1205 Unexpected section title.
1206 <literal_block xml:space="preserve">
1217 ========= =====================================================================
1218 Inclusion .. include::
1220 Note The first row of this table may expand
1221 to accommodate long filesystem paths.
1222 ========= =====================================================================
1223 """ % ('\n'.join([' %-65s' % include2
[part
* 65 : (part
+ 1) * 65]
1224 for part
in range(len(include2
) // 65 + 1)])),
1226 <document source="test data">
1229 <colspec colwidth="9">
1230 <colspec colwidth="69">
1238 Here are some paragraphs
1239 that can appear at any level.
1241 This file (include2.txt) is used by
1251 The first row of this table may expand
1252 to accommodate long filesystem paths.
1257 if __name__
== '__main__':
1259 unittest
.main(defaultTest
='suite')