add SimpleTableParser test case
[docutils.git] / test / test_parsers / test_rst / test_SimpleTableParser.py
blob503d1ba1d0acf9bd58c00e32091704283510f3ef
1 #! /usr/bin/env python
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 from __init__ import DocutilsTestSupport
13 def suite():
14 s = DocutilsTestSupport.SimpleTableParserTestSuite()
15 s.generateTests(totest)
16 return s
18 totest = {}
20 totest['simple_tables'] = [
21 ["""\
22 ============ ============
23 A table with two columns.
24 ============ ============
25 """,
26 ([12, 12],
27 [],
28 [[[0, 0, 1, ['A table with']],
29 [0, 0, 1, ['two columns.']]]])],
30 ["""\
31 ============ ============
32 A table with two columns
33 and two rows.
34 ============ ============
35 """,
36 ([12, 12],
37 [],
38 [[[0, 0, 1, ['A table with']],
39 [0, 0, 1, ['two columns']]],
40 [[0, 0, 2, ['and']],
41 [0, 0, 2, ['two rows.']]]])],
42 ["""\
43 ======================================
44 The last row might stick into the margin
45 second row.
46 ======================================
47 """,
48 ([40],
49 [],
50 [[[0, 0, 1, ['The last row might stick into the margin']]],
51 [[0, 0, 2, ['second row.']]]])],
52 ["""\
53 ========== ===========
54 A table with four rows,
55 -----------------------
56 and two columns.
57 First and last rows
58 contain column spans.
59 =======================
60 """,
61 ([10, 11],
62 [],
63 [[[0, 1, 1, ['A table with four rows,']]],
64 [[0, 0, 3, ['and two']],
65 [0, 0, 3, ['columns.']]],
66 [[0, 0, 4, ['First and']],
67 [0, 0, 4, ['last rows']]],
68 [[0, 1, 5, ['contain column spans.']]]])],
69 ["""\
70 ======= ===== ======
71 A bad table cell 2
72 cell 3 cell 4
73 ============ ======
74 """,
75 'TableMarkupError: Text in column margin at line offset 1.'],
76 ["""\
77 ====== ===== ======
78 row one
79 Another bad table
80 ====== ===== ======
81 """,
82 'TableMarkupError: Text in column margin at line offset 2.'],
83 ["""\
84 =========== ================
85 A table with two header rows,
86 -----------------------------
87 the first with a span.
88 =========== ================
89 Two body rows,
90 the second with a span.
91 =============================
92 """,
93 ([11, 16],
94 [[[0, 1, 1, ['A table with two header rows,']]],
95 [[0, 0, 3, ['the first']],
96 [0, 0, 3, ['with a span.']]]],
97 [[[0, 0, 5, ['Two body']],
98 [0, 0, 5, ['rows,']]],
99 [[0, 1, 6, ['the second with a span.']]]])],
100 ["""\
101 ============ =============
102 A table with two head/body
103 ============ =============
104 row separators.
105 ============ =============
106 That's bad.
107 ============ =============
108 """,
109 'TableMarkupError: Multiple head/body row separators in table '
110 '(at line offset 2 and 4); only one allowed.'],
111 ["""\
112 ============ ============
113 ============ ============
114 """,
115 ([12, 12],
117 [[[0, 0, 1, []],
118 [0, 0, 1, []]]])],
119 # ["""\
120 # ============== ==========
121 # Table with row separators
122 # ============== ==========
123 # and blank
124 # -------------- ----------
125 # entries
126 # -------------- ----------
127 # in first
128 # -------------- ----------
129 # columns.
130 # ============== ==========
131 # """,
132 # '']
136 if __name__ == '__main__':
137 import unittest
138 unittest.main(defaultTest='suite')