~ubuntu-branches/ubuntu/jaunty/python-docutils/jaunty

« back to all changes in this revision

Viewing changes to test/test_rst/test_SimpleTableParser.py

  • Committer: Bazaar Package Importer
  • Author(s): martin f. krafft
  • Date: 2006-07-10 11:45:05 UTC
  • mfrom: (2.1.4 edgy)
  • Revision ID: james.westby@ubuntu.com-20060710114505-otkhqcslevewxmz5
Tags: 0.4-3
Added build dependency on python-central (closes: #377580).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /usr/bin/env python
2
 
 
3
 
"""
4
 
:Author: David Goodger
5
 
:Contact: goodger@users.sourceforge.net
6
 
:Revision: $Revision: 1.1 $
7
 
:Date: $Date: 2002/07/18 01:39:17 $
8
 
:Copyright: This module has been placed in the public domain.
9
 
 
10
 
Tests for states.py.
11
 
"""
12
 
 
13
 
from __init__ import DocutilsTestSupport
14
 
 
15
 
def suite():
16
 
    s = DocutilsTestSupport.SimpleTableParserTestSuite()
17
 
    s.generateTests(totest)
18
 
    return s
19
 
 
20
 
totest = {}
21
 
 
22
 
totest['simple_tables'] = [
23
 
["""\
24
 
============  ============
25
 
A table with  two columns.
26
 
============  ============
27
 
""",
28
 
([12, 12],
29
 
 [],
30
 
 [[(0, 0, 1, ['A table with']),
31
 
   (0, 0, 1, ['two columns.'])]])],
32
 
["""\
33
 
============  ============
34
 
A table with  two columns
35
 
and           two rows.
36
 
============  ============
37
 
""",
38
 
([12, 12],
39
 
 [],
40
 
 [[(0, 0, 1, ['A table with']),
41
 
   (0, 0, 1, ['two columns'])],
42
 
  [(0, 0, 2, ['and']),
43
 
   (0, 0, 2, ['two rows.'])]])],
44
 
["""\
45
 
==========  ===========
46
 
A table with four rows,
47
 
-----------------------
48
 
and two     columns.   
49
 
First and   last rows     
50
 
contain column spans.   
51
 
=======================
52
 
""",
53
 
([10, 11],
54
 
 [],
55
 
 [[(0, 1, 1, ['A table with four rows,'])],
56
 
  [(0, 0, 3, ['and two']),
57
 
   (0, 0, 3, ['columns.'])],
58
 
  [(0, 0, 4, ['First and']),
59
 
   (0, 0, 4, ['last rows'])],
60
 
  [(0, 1, 5, ['contain column spans.'])]])],
61
 
["""\
62
 
=======  =====  ======
63
 
A bad table     cell 2
64
 
cell 3          cell 4
65
 
============  ======
66
 
""",
67
 
'TableMarkupError: Text in column margin at line offset 1.'],
68
 
["""\
69
 
===========  ================
70
 
A table with two header rows,
71
 
-----------------------------
72
 
the first    with a span.    
73
 
===========  ================
74
 
Two body     rows,           
75
 
the second with a span.      
76
 
=============================
77
 
""",
78
 
([11, 16],
79
 
 [[(0, 1, 1, ['A table with two header rows,'])],
80
 
  [(0, 0, 3, ['the first']),
81
 
   (0, 0, 3, ['with a span.'])]],
82
 
 [[(0, 0, 5, ['Two body']),
83
 
   (0, 0, 5, ['rows,'])],
84
 
  [(0, 1, 6, ['the second with a span.'])]])],
85
 
["""\
86
 
============  =============
87
 
A table with  two head/body
88
 
============  =============
89
 
row           separators.
90
 
============  =============
91
 
That's bad.
92
 
============  =============
93
 
""",
94
 
'TableMarkupError: Multiple head/body row separators in table '
95
 
'(at line offset 2 and 4); only one allowed.'],
96
 
]
97
 
 
98
 
 
99
 
if __name__ == '__main__':
100
 
    import unittest
101
 
    unittest.main(defaultTest='suite')