5 # Author: David Goodger <goodger@python.org>
6 # Copyright: This module has been placed in the public domain.
12 from __init__
import DocutilsTestSupport
15 s
= DocutilsTestSupport
.GridTableParserTestSuite()
16 s
.generateTests(totest
)
21 totest
['grid_tables'] = [
23 +-------------------------------------+
24 | A table with one cell and one line. |
25 +-------------------------------------+
27 [(0, 0, 2, 38, ['A table with one cell and one line.'])],
30 [[(0, 0, 1, ['A table with one cell and one line.'])]])],
32 +--------------+--------------+
33 | A table with | two columns. |
34 +--------------+--------------+
36 [(0, 0, 2, 15, ['A table with']),
37 (0, 15, 2, 30, ['two columns.'])],
40 [[(0, 0, 1, ['A table with']),
41 (0, 0, 1, ['two columns.'])]])],
42 # Combining chars in grid tables still fail
44 # +--------------+------------------+
45 # | A tāble w̅ith | comb̲ining chars. |
46 # +--------------+------------------+
48 # [(0, 0, 2, 15, [u'A table with']),
49 # (0, 15, 2, 30, [u'combining chars.'])],
52 # [[(0, 0, 1, [u'A table with']),
53 # (0, 0, 1, [u'combining chars.'])]])],
55 +--------------+-------------+
56 | A table with | two columns |
57 +--------------+-------------+
59 +--------------+-------------+
61 [(0, 0, 2, 15, ['A table with']),
62 (0, 15, 2, 29, ['two columns']),
63 (2, 0, 4, 15, ['and']),
64 (2, 15, 4, 29, ['two rows.'])],
67 [[(0, 0, 1, ['A table with']),
68 (0, 0, 1, ['two columns'])],
70 (0, 0, 3, ['two rows.'])]])],
72 +--------------------------+
73 | A table with three rows, |
74 +------------+-------------+
75 | and two | columns. |
76 +------------+-------------+
77 | First and last rows |
78 | contain column spans. |
79 +--------------------------+
81 [(0, 0, 2, 27, ['A table with three rows,']),
82 (2, 0, 4, 13, ['and two']),
83 (2, 13, 4, 27, ['columns.']),
84 (4, 0, 7, 27, ['First and last rows', 'contain column spans.'])],
87 [[(0, 1, 1, ['A table with three rows,']),
89 [(0, 0, 3, ['and two']),
90 (0, 0, 3, ['columns.'])],
91 [(0, 1, 5, ['First and last rows', 'contain column spans.']),
94 +------------+-------------+---------------+
95 | A table | two rows in | and row spans |
96 | with three +-------------+ to left and |
97 | columns, | the middle, | right. |
98 +------------+-------------+---------------+
100 [(0, 0, 4, 13, ['A table', 'with three', 'columns,']),
101 (0, 13, 2, 27, ['two rows in']),
102 (0, 27, 4, 43, ['and row spans', 'to left and', 'right.']),
103 (2, 13, 4, 27, ['the middle,'])],
106 [[(1, 0, 1, ['A table', 'with three', 'columns,']),
107 (0, 0, 1, ['two rows in']),
108 (1, 0, 1, ['and row spans', 'to left and', 'right.'])],
110 (0, 0, 3, ['the middle,']),
113 +------------+-------------+---------------+
114 | A table | | two rows in | and funny |
115 | with 3 +--+-------------+-+ stuff. |
116 | columns, | the middle, | | |
117 +------------+-------------+---------------+
119 [(0, 0, 4, 13, ['A table |', 'with 3 +--', 'columns,']),
120 (0, 13, 2, 27, ['two rows in']),
121 (0, 27, 4, 43, [' and funny', '-+ stuff.', ' |']),
122 (2, 13, 4, 27, ['the middle,'])],
125 [[(1, 0, 1, ['A table |', 'with 3 +--', 'columns,']),
126 (0, 0, 1, ['two rows in']),
127 (1, 0, 1, [' and funny', '-+ stuff.', ' |'])],
129 (0, 0, 3, ['the middle,']),
132 +-----------+-------------------------+
133 | W/NW cell | N/NE cell |
134 | +-------------+-----------+
135 | | Middle cell | E/SE cell |
136 +-----------+-------------+ |
138 +-------------------------+-----------+
140 [(0, 0, 4, 12, ['W/NW cell', '', '']),
141 (0, 12, 2, 38, ['N/NE cell']),
142 (2, 12, 4, 26, ['Middle cell']),
143 (2, 26, 6, 38, ['E/SE cell', '', '']),
144 (4, 0, 6, 26, ['S/SE cell'])],
147 [[(1, 0, 1, ['W/NW cell', '', '']),
148 (0, 1, 1, ['N/NE cell']),
151 (0, 0, 3, ['Middle cell']),
152 (1, 0, 3, ['E/SE cell', '', ''])],
153 [(0, 1, 5, ['S/SE cell']),
157 +--------------+-------------+
160 | Cells must be rectangles. |
161 +----------------------------+
163 'TableMarkupError: Malformed table; parse incomplete.',
164 'TableMarkupError: Malformed table; parse incomplete.'],
166 +-------------------------------+
167 | A table with two header rows, |
168 +------------+------------------+
169 | the first | with a span. |
170 +============+==================+
172 +------------+------------------+
173 | the second with a span. |
174 +-------------------------------+
176 [(0, 0, 2, 32, ['A table with two header rows,']),
177 (2, 0, 4, 13, ['the first']),
178 (2, 13, 4, 32, ['with a span.']),
179 (4, 0, 6, 13, ['Two body']),
180 (4, 13, 6, 32, ['rows,']),
181 (6, 0, 8, 32, ['the second with a span.'])],
183 [[(0, 1, 1, ['A table with two header rows,']),
185 [(0, 0, 3, ['the first']),
186 (0, 0, 3, ['with a span.'])]],
187 [[(0, 0, 5, ['Two body']),
188 (0, 0, 5, ['rows,'])],
189 [(0, 1, 7, ['the second with a span.']),
192 +-------------------------------+
193 | A table with two head/body |
194 +=============+=================+
195 | row | separators. |
196 +=============+=================+
198 +-------------+-----------------+
200 'TableMarkupError: Multiple head/body row separators '
201 '(table lines 3 and 5); only one allowed.',
202 'TableMarkupError: Multiple head/body row separators '
203 '(table lines 3 and 5); only one allowed.'],
205 +-------------------------------------+
207 +-------------------------------------+
209 [(0, 0, 2, 38, [''])],
212 [[(0, 0, 1, [''])]])],
216 if __name__
== '__main__':
218 unittest
.main(defaultTest
='suite')