]>
git.scottworley.com Git - paperdoorknob/blob - glowfic_test.py
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 glowfic
import chunkDOMs
15 class TestSplit(unittest
.TestCase
):
17 def testSplit1(self
) -> None:
18 soup
= BeautifulSoup(b
'''
19 <html><body><div class="post-container post-post">
21 </div></body></html>''', 'html.parser')
22 self
.assertEqual([list(t
.stripped_strings
) for t
in chunkDOMs(soup
)],
25 def testSplit2(self
) -> None:
26 soup
= BeautifulSoup(b
'''
28 <div class="post-container post-post">The "post"</div>
29 <div class="flat-post-replies">
30 <div class="post-container post-reply">The "reply"</div>
32 </body></html>''', 'html.parser')
33 self
.assertEqual([list(t
.stripped_strings
) for t
in chunkDOMs(soup
)],
34 [['The "post"'], ['The "reply"']])
36 def testSplit3(self
) -> None:
37 soup
= BeautifulSoup(b
'''
39 <div class="post-container post-post">The "post"</div>
40 <div class="flat-post-replies">
41 <div class="post-container post-reply">1st reply</div>
42 <div class="post-container post-reply">2nd reply</div>
44 </body></html>''', 'html.parser')
45 self
.assertEqual([list(t
.stripped_strings
) for t
in chunkDOMs(soup
)],
46 [['The "post"'], ['1st reply'], ['2nd reply']])
49 if __name__
== '__main__':