]>
git.scottworley.com Git - paperdoorknob/blob - domfilter_test.py
c3c8ee2936b3a88b21739a6afc8832a41ac6766a
1 # paperdoorknob: Print glowfic
3 # This program is free software: you can redistribute it and/or modify it
4 # under the terms of the GNU General Public License as published by the
5 # Free Software Foundation, version 3.
10 from bs4
import BeautifulSoup
12 from domfilter
import ApplyDOMFilters
15 class TestDOMFilters(unittest
.TestCase
):
17 def setUp(self
) -> None:
18 self
._html
= BeautifulSoup(b
'''
19 <div class="post-container post-post">
20 <div class="post-edit-box">This is the edit box</div>
22 <div class="post-footer">This is the footer</div>
23 </div>''', 'html.parser')
25 def testStripFooters(self
) -> None:
26 ApplyDOMFilters("NoFooter", self
._html
)
27 self
.assertEqual(list(self
._html
.stripped_strings
),
28 ["This is the edit box", "This is glowfic"])
30 def testStripEditBoxes(self
) -> None:
31 ApplyDOMFilters("NoEdit", self
._html
)
32 self
.assertEqual(list(self
._html
.stripped_strings
),
33 ["This is glowfic", "This is the footer"])
35 def testStripFootersAndEditBoxes(self
) -> None:
36 ApplyDOMFilters("NoEdit,NoFooter", self
._html
)
37 self
.assertEqual(list(self
._html
.stripped_strings
),
41 if __name__
== '__main__':