forked from douban/code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_htmlprocessor.py
More file actions
40 lines (35 loc) · 1.22 KB
/
test_htmlprocessor.py
File metadata and controls
40 lines (35 loc) · 1.22 KB
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
from tests.base import TestCase
from vilya.libs.htmlprocessor import html_index_content
class TestHTMLProcessor(TestCase):
def test_process_whitespaces(self):
html = '''
<h1>Title</h1>
<br />
<p>This is a paragraph.</p>
'''
res = html_index_content(html)
assert res == "Title This is a paragraph."
def test_remove_script_tags(self):
html = '''
<h1>Title</h1>
<script type="text/javascript">
</script>
'''
res = html_index_content(html)
assert res == "Title"
def test_unescape(self):
html = '''
<h1>Title</h1>
<script type="text/javascript">
</script>
<footer>
<a href="./" class="button_accent">
Back to blog
</a>
</footer>
<code>
print 1<3
</code>
'''
res = html_index_content(html)
assert res == "Title Back to blog print 1<3"