-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_pcleaner.py
31 lines (23 loc) · 1.63 KB
/
test_pcleaner.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
import unittest
import pcleaner
class TestParagraphCleaner(unittest.TestCase):
def test_paragraph_without_content(self):
html = "<html><p>One paragraph with content</p><p></p></html>"
self.assertEqual(pcleaner.clean(html), "<html><p>One paragraph with content</p></html>")
def test_paragraph_with_one_blank(self):
html = "<html><p>One paragraph with content</p><p> </p></html>"
self.assertEqual(pcleaner.clean(html), "<html><p>One paragraph with content</p></html>")
def test_paragraph_with_some_blanks(self):
html = "<html><p>One paragraph with content</p><p> </p></html>"
self.assertEqual(pcleaner.clean(html), "<html><p>One paragraph with content</p></html>")
def test_more_blank_paragraphs(self):
html = "<html><p>One paragraph with content</p><p> </p><p> </p><p></p><p>other par</p></html>"
self.assertEqual(pcleaner.clean(html), "<html><p>One paragraph with content</p><p>other par</p></html>")
def test_blank_paragraphs_with_attributes(self):
html = "<html><p>One paragraph with content</p><p> </p><p style='margin: 5'> </p><p></p><p>other par</p></html>"
self.assertEqual(pcleaner.clean(html), "<html><p>One paragraph with content</p><p>other par</p></html>")
def test_paragraphs_with_newline_remains(self):
html = "<html><p>One paragraph with content</p><p>\n </p><p style='margin: 5'> </p><p></p><p>other par</p></html>"
self.assertEqual(pcleaner.clean(html), "<html><p>One paragraph with content</p><p>\n </p><p>other par</p></html>")
if __name__ == '__main__':
unittest.main()