]> git.scottworley.com Git - paperdoorknob/blame - domfilter_test.py
texfilter to work around \emph nesting issue
[paperdoorknob] / domfilter_test.py
CommitLineData
8be20b9d
SW
1# paperdoorknob: Print glowfic
2#
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.
6
7
8import unittest
9
10from bs4 import BeautifulSoup
11
12from domfilter import ApplyDOMFilters
13
14
15class TestDOMFilters(unittest.TestCase):
16
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>
21 This is glowfic
22 <div class="post-footer">This is the footer</div>
23 </div>''', 'html.parser')
24
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"])
29
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"])
34
35 def testStripFootersAndEditBoxes(self) -> None:
36 ApplyDOMFilters("NoEdit,NoFooter", self._html)
37 self.assertEqual(list(self._html.stripped_strings),
38 ["This is glowfic"])
39
40
41if __name__ == '__main__':
42 unittest.main()