diff options
author | Leonard Richardson <leonardr@segfault.org> | 2018-12-23 17:19:27 -0500 |
---|---|---|
committer | Leonard Richardson <leonardr@segfault.org> | 2018-12-23 17:19:27 -0500 |
commit | fe3f12db5a055a3c3e50f1bec609b9a030cd7909 (patch) | |
tree | 4d577e78be0496c17271d8e9d7f52af9343b7780 /bs4/tests/test_html5lib.py | |
parent | db096322896ab879b7b468f645e81a7bf91ddc94 (diff) | |
parent | 598b63d64d7c0849b734526ae8ecb27635f421a0 (diff) |
Merged in next_previous_fixes from Isaac Muse. [bug=1782928,1798699]
Diffstat (limited to 'bs4/tests/test_html5lib.py')
-rw-r--r-- | bs4/tests/test_html5lib.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/bs4/tests/test_html5lib.py b/bs4/tests/test_html5lib.py index 0f89d62..3a04787 100644 --- a/bs4/tests/test_html5lib.py +++ b/bs4/tests/test_html5lib.py @@ -128,3 +128,43 @@ class HTML5LibBuilderSmokeTest(SoupTest, HTML5TreeBuilderSmokeTest): markup = b"""<table><td></tbody>A""" soup = self.soup(markup) self.assertEqual(u"<body>A<table><tbody><tr><td></td></tr></tbody></table></body>", soup.body.decode()) + + def test_extraction(self): + """ + Test that extraction does not destroy the tree. + + https://bugs.launchpad.net/beautifulsoup/+bug/1782928 + """ + + markup = """ +<html><head></head> +<style> +</style><script></script><body><p>hello</p></body></html> +""" + soup = self.soup(markup) + [s.extract() for s in soup('script')] + [s.extract() for s in soup('style')] + + self.assertEqual(len(soup.find_all("p")), 1) + + def test_empty_comment(self): + """ + Test that empty comment does not break structure. + + https://bugs.launchpad.net/beautifulsoup/+bug/1806598 + """ + + markup = """ +<html> +<body> +<form> +<!----><input type="text"> +</form> +</body> +</html> +""" + soup = self.soup(markup) + inputs = [] + for form in soup.find_all('form'): + inputs.extend(form.find_all('input')) + self.assertEqual(len(inputs), 1) |