Release 0.5: added empty "Changes Since 0.5" section
[docutils.git] / test / test_parsers / test_rst / test_SimpleTableParser.py
blob2c0bfa524fd5de66982ec28f22ce700f75656ee2
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 A table with four rows,
45 -----------------------
46 and two columns.
47 First and last rows
48 contain column spans.
49 =======================
50 """,
51 ([10, 11],
52 [],
53 [[[0, 1, 1, ['A table with four rows,']]],
54 [[0, 0, 3, ['and two']],
55 [0, 0, 3, ['columns.']]],
56 [[0, 0, 4, ['First and']],
57 [0, 0, 4, ['last rows']]],
58 [[0, 1, 5, ['contain column spans.']]]])],
59 ["""\
60 ======= ===== ======
61 A bad table cell 2
62 cell 3 cell 4
63 ============ ======
64 """,
65 'TableMarkupError: Text in column margin at line offset 1.'],
66 ["""\
67 =========== ================
68 A table with two header rows,
69 -----------------------------
70 the first with a span.
71 =========== ================
72 Two body rows,
73 the second with a span.
74 =============================
75 """,
76 ([11, 16],
77 [[[0, 1, 1, ['A table with two header rows,']]],
78 [[0, 0, 3, ['the first']],
79 [0, 0, 3, ['with a span.']]]],
80 [[[0, 0, 5, ['Two body']],
81 [0, 0, 5, ['rows,']]],
82 [[0, 1, 6, ['the second with a span.']]]])],
83 ["""\
84 ============ =============
85 A table with two head/body
86 ============ =============
87 row separators.
88 ============ =============
89 That's bad.
90 ============ =============
91 """,
92 'TableMarkupError: Multiple head/body row separators in table '
93 '(at line offset 2 and 4); only one allowed.'],
94 ["""\
95 ============ ============
96 ============ ============
97 """,
98 ([12, 12],
99 [],
100 [[[0, 0, 1, []],
101 [0, 0, 1, []]]])],
102 # ["""\
103 # ============== ==========
104 # Table with row separators
105 # ============== ==========
106 # and blank
107 # -------------- ----------
108 # entries
109 # -------------- ----------
110 # in first
111 # -------------- ----------
112 # columns.
113 # ============== ==========
114 # """,
115 # '']
119 if __name__ == '__main__':
120 import unittest
121 unittest.main(defaultTest='suite')