5
:Contact: goodger@users.sourceforge.net
6
:Revision: $Revision: 1.3 $
7
:Date: $Date: 2002/07/18 01:47:22 $
8
:Copyright: This module has been placed in the public domain.
13
from __init__ import DocutilsTestSupport
16
s = DocutilsTestSupport.GridTableParserTestSuite()
17
s.generateTests(totest)
22
totest['grid_tables'] = [
24
+-------------------------------------+
25
| A table with one cell and one line. |
26
+-------------------------------------+
28
[(0, 0, 2, 38, ['A table with one cell and one line.'])],
31
[[(0, 0, 1, ['A table with one cell and one line.'])]])],
33
+--------------+--------------+
34
| A table with | two columns. |
35
+--------------+--------------+
37
[(0, 0, 2, 15, ['A table with']),
38
(0, 15, 2, 30, ['two columns.'])],
41
[[(0, 0, 1, ['A table with']),
42
(0, 0, 1, ['two columns.'])]])],
44
+--------------+-------------+
45
| A table with | two columns |
46
+--------------+-------------+
48
+--------------+-------------+
50
[(0, 0, 2, 15, ['A table with']),
51
(0, 15, 2, 29, ['two columns']),
52
(2, 0, 4, 15, ['and']),
53
(2, 15, 4, 29, ['two rows.'])],
56
[[(0, 0, 1, ['A table with']),
57
(0, 0, 1, ['two columns'])],
59
(0, 0, 3, ['two rows.'])]])],
61
+--------------------------+
62
| A table with three rows, |
63
+------------+-------------+
64
| and two | columns. |
65
+------------+-------------+
66
| First and last rows |
67
| contain column spans. |
68
+--------------------------+
70
[(0, 0, 2, 27, ['A table with three rows,']),
71
(2, 0, 4, 13, ['and two']),
72
(2, 13, 4, 27, ['columns.']),
73
(4, 0, 7, 27, ['First and last rows', 'contain column spans.'])],
76
[[(0, 1, 1, ['A table with three rows,']),
78
[(0, 0, 3, ['and two']),
79
(0, 0, 3, ['columns.'])],
80
[(0, 1, 5, ['First and last rows', 'contain column spans.']),
83
+------------+-------------+---------------+
84
| A table | two rows in | and row spans |
85
| with three +-------------+ to left and |
86
| columns, | the middle, | right. |
87
+------------+-------------+---------------+
89
[(0, 0, 4, 13, ['A table', 'with three', 'columns,']),
90
(0, 13, 2, 27, ['two rows in']),
91
(0, 27, 4, 43, ['and row spans', 'to left and', 'right.']),
92
(2, 13, 4, 27, ['the middle,'])],
95
[[(1, 0, 1, ['A table', 'with three', 'columns,']),
96
(0, 0, 1, ['two rows in']),
97
(1, 0, 1, ['and row spans', 'to left and', 'right.'])],
99
(0, 0, 3, ['the middle,']),
102
+------------+-------------+---------------+
103
| A table | | two rows in | and funny |
104
| with 3 +--+-------------+-+ stuff. |
105
| columns, | the middle, | | |
106
+------------+-------------+---------------+
108
[(0, 0, 4, 13, ['A table |', 'with 3 +--', 'columns,']),
109
(0, 13, 2, 27, ['two rows in']),
110
(0, 27, 4, 43, [' and funny', '-+ stuff.', ' |']),
111
(2, 13, 4, 27, ['the middle,'])],
114
[[(1, 0, 1, ['A table |', 'with 3 +--', 'columns,']),
115
(0, 0, 1, ['two rows in']),
116
(1, 0, 1, [' and funny', '-+ stuff.', ' |'])],
118
(0, 0, 3, ['the middle,']),
121
+-----------+-------------------------+
122
| W/NW cell | N/NE cell |
123
| +-------------+-----------+
124
| | Middle cell | E/SE cell |
125
+-----------+-------------+ |
127
+-------------------------+-----------+
129
[(0, 0, 4, 12, ['W/NW cell', '', '']),
130
(0, 12, 2, 38, ['N/NE cell']),
131
(2, 12, 4, 26, ['Middle cell']),
132
(2, 26, 6, 38, ['E/SE cell', '', '']),
133
(4, 0, 6, 26, ['S/SE cell'])],
136
[[(1, 0, 1, ['W/NW cell', '', '']),
137
(0, 1, 1, ['N/NE cell']),
140
(0, 0, 3, ['Middle cell']),
141
(1, 0, 3, ['E/SE cell', '', ''])],
142
[(0, 1, 5, ['S/SE cell']),
146
+--------------+-------------+
149
| Cells must be rectangles. |
150
+----------------------------+
152
'TableMarkupError: Malformed table; parse incomplete.',
153
'TableMarkupError: Malformed table; parse incomplete.'],
155
+-------------------------------+
156
| A table with two header rows, |
157
+------------+------------------+
158
| the first | with a span. |
159
+============+==================+
161
+------------+------------------+
162
| the second with a span. |
163
+-------------------------------+
165
[(0, 0, 2, 32, ['A table with two header rows,']),
166
(2, 0, 4, 13, ['the first']),
167
(2, 13, 4, 32, ['with a span.']),
168
(4, 0, 6, 13, ['Two body']),
169
(4, 13, 6, 32, ['rows,']),
170
(6, 0, 8, 32, ['the second with a span.'])],
172
[[(0, 1, 1, ['A table with two header rows,']),
174
[(0, 0, 3, ['the first']),
175
(0, 0, 3, ['with a span.'])]],
176
[[(0, 0, 5, ['Two body']),
177
(0, 0, 5, ['rows,'])],
178
[(0, 1, 7, ['the second with a span.']),
181
+-------------------------------+
182
| A table with two head/body |
183
+=============+=================+
184
| row | separators. |
185
+=============+=================+
187
+-------------+-----------------+
189
'TableMarkupError: Multiple head/body row separators in table '
190
'(at line offset 2 and 4); only one allowed.',
191
'TableMarkupError: Multiple head/body row separators in table '
192
'(at line offset 2 and 4); only one allowed.'],
196
if __name__ == '__main__':
198
unittest.main(defaultTest='suite')