diff options
author | Isaac Muse <isaacmuse@gmail.com> | 2018-12-22 14:25:35 -0700 |
---|---|---|
committer | Isaac Muse <isaacmuse@gmail.com> | 2018-12-22 14:25:35 -0700 |
commit | 598b63d64d7c0849b734526ae8ecb27635f421a0 (patch) | |
tree | fa32a7f3eb1b3de7e452a914145feed28342f76c /bs4/tests/test_html5lib.py | |
parent | 427a877bc1a02fa95d83ac2500f94cba2e91501f (diff) |
Fix next and previous linkage issues. Fixes issues #1806598 and #1782928.
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) |