forked from phuel/tables_extended
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
80 lines (67 loc) · 1.9 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import unittest
from extension_testcase import ExtensionTestCase
class TestExtension(ExtensionTestCase):
def test_headerless_table(self):
input = '''
|----|----|
|r1c1|r1c2|
'''
self.check_text(input, '''
<table><tbody>
<tr><td>r1c1</td><td>r1c2</td></tr>
</tbody></table>''')
def test_colspan(self):
input = '''
|----|----|----|
|r1c1 ||r1c3|
'''
self.check_text(input, '''
<table><tbody>
<tr><td colspan="2">r1c1</td> <td>r1c3</td></tr>
</tbody></table>''')
def test_rowspan(self):
input = '''
|----|----|----|
|r1c1|r1c2|r1c3|
|_ _|r2c2|r2c3|
|r3c1|_ _|r3c3|
'''
self.check_text(input, '''
<table><tbody>
<tr><td rowspan="2">r1c1</td> <td>r1c2</td> <td>r1c3</td></tr>
<tr> <td rowspan="2">r2c2</td> <td>r2c3</td></tr>
<tr><td>r3c1</td> <td>r3c3</td></tr>
</tbody></table>''')
def test_rowspan_and_colspan(self):
input = '''
|----|----|----|----|
|r1c1|r1c2|r1c3|r1c4|
|r2c1|r2c2 ||r2c4|
|r3c1|_ _||r3c4|
|r4c1|r4c2|r4c3|r4c4|
'''
self.check_text(input, '''
<table><tbody>
<tr><td>r1c1</td> <td>r1c2</td> <td>r1c3</td> <td>r1c4</td></tr>
<tr><td>r2c1</td> <td colspan="2" rowspan="2">r2c2</td> <td>r2c4</td></tr>
<tr><td>r3c1</td> <td>r3c4</td></tr>
<tr><td>r4c1</td> <td>r4c2</td> <td>r4c3</td> <td>r4c4</td></tr>
</tbody></table>''')
def test_valign(self):
input = '''
|----|----|----|----|
|r1c1|r1c2|r1c3|r1c4|
|____|_^^_|_--_|_==_|
'''
self.check_text(input, '''
<table><tbody>
<tr>
<td rowspan="2">r1c1</td>
<td rowspan="2" valign="top">r1c2</td>
<td rowspan="2" valign="middle">r1c3</td>
<td rowspan="2" valign="bottom">r1c4</td>
</tr>
<tr></tr>
</tbody></table>''')
if __name__ == '__main__':
unittest.main()