forked from phuel/tables_extended
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_for_compatibility.py
100 lines (84 loc) · 2.67 KB
/
test_for_compatibility.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import unittest
import markdown
from extension_testcase import ExtensionTestCase
from tables_extended import TableExtension
class TestExtensionForCompatibility(ExtensionTestCase):
def test_compatibilty(self):
self.check_file('testdata/tables.txt', 'testdata/tables.html')
def test_compatibilty_php(self):
self.check_file('testdata/tables_php.txt', 'testdata/tables_php.html')
def test_empty_cells(self):
"""Empty cells (nbsp)."""
input = """
| Second Header
------------- | -------------
| Content Cell
Content Cell |
"""
self.check_text(input, """
<table>
<thead>
<tr>
<th> </th>
<th>Second Header</th>
</tr>
</thead>
<tbody>
<tr>
<td> </td>
<td>Content Cell</td>
</tr>
<tr>
<td>Content Cell</td>
<td> </td>
</tr>
</tbody>
</table>
"""
)
def test_cell_row_span(self):
input = """
| Column 1 | Col 2 | Big row span |
|:-----------------------:|-------| -------------- |
| r1_c1 spans two cols || One large cell |
| r2_c1 spans two rows | r2_c2 | |
|_^ _| r3_c2 | |
| ______  | r4_c2 |_ _|
"""
self.check_text(input, """
<table>
<thead>
<tr><th align="center">Column 1</th><th>Col 2</th><th>Big row span</th></tr>
</thead>
<tbody>
<tr><td align="center" colspan="2">r1_c1 spans two cols</td><td rowspan="4">One large cell</td></tr>
<tr><td align="center" rowspan="2" valign="top">r2_c1 spans two rows</td><td>r2_c2</td></tr>
<tr><td>r3_c2</td></tr>
<tr><td align="center">______ </td><td>r4_c2</td></tr>
</tbody>
</table>
""")
def test_multiple_alignments_are_not_allowed(self):
input = """
| Column 1 |
|-----------------------|
| r1_c1 spans two cols |
|_^= _|
"""
self.assertRaises(ValueError, markdown.markdown, input, extensions=[TableExtension()])
input = """
| Column 1 |
|-----------------------|
| r1_c1 spans two cols |
|_^- _|
"""
self.assertRaises(ValueError, markdown.markdown, input, extensions=[TableExtension()])
input = """
| Column 1 |
|-----------------------|
| r1_c1 spans two cols |
|_-= _|
"""
self.assertRaises(ValueError, markdown.markdown, input, extensions=[TableExtension()])
if __name__ == '__main__':
unittest.main()