-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_syntax.py
executable file
·106 lines (79 loc) · 1.43 KB
/
test_syntax.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
101
102
103
#! /usr/bin/env python
import unittest
from syntax_highlight import *
class TestSyntaxHighlight (unittest.TestCase):
def test_html_py (self):
html = '''
<html>
<body>
<p>Some text</p>
<pre>
<code>
import sys
def something (foo):
return foo
sys.exit (1)
</code>
</pre>
<p> some more text </p>
</body>
</html>
'''
s = SyntaxHighlight ()
print ( s.do_filter_part ('', html, 'text/html', False) )
def test_text_c (self):
text = '''```
int main (int argc, char ** argv) {
int a = 0;
int b = 2;
int c;
c = a + b;
return c;
}
```'''
html = '''```<br>
int main (int argc, char ** argv) {<br>
int a = 0;<br>
int b = 2;<br>
int c;<br>
<br>
c = a + b;<br>
return c;<br>
}<br>
<br>
```<br>
<br>'''
s = SyntaxHighlight ()
print ( s.do_filter_part (text, html, 'text/plain', False) )
def test_two_segments (self):
text = '''```
<html>
<head>
</head>
</html>
```
```
import sys
def foo (bar):
return bar + 1
```
'''
html = '''```<br>
<html><br>
<head><br>
</head><br>
</html><br>
```<br>
<br>
```<br>
import sys<br>
<br>
def foo (bar):<br>
return bar + 1<br>
```<br>
<br>
<br>'''
s = SyntaxHighlight ()
print ( s.do_filter_part (text, html, 'text/plain', False) )
if __name__ == '__main__':
unittest.main ()