diff options
author | Leonard Richardson <leonardr@segfault.org> | 2012-08-21 09:13:11 -0400 |
---|---|---|
committer | Leonard Richardson <leonardr@segfault.org> | 2012-08-21 09:13:11 -0400 |
commit | 1bdebd326cec9699cd18f040a32a79b8b925eb84 (patch) | |
tree | c33860d35fc43f81af423703130fbd7c68505c20 /bs4/testing.py | |
parent | d95ac0003965b4c70157d456fce4d5f1e03ab2d6 (diff) |
Fixed a problem with the html5lib builder not handling comments correctly.
Diffstat (limited to 'bs4/testing.py')
-rw-r--r-- | bs4/testing.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/bs4/testing.py b/bs4/testing.py index 30e74f4..0f052eb 100644 --- a/bs4/testing.py +++ b/bs4/testing.py @@ -159,6 +159,12 @@ class HTMLTreeBuilderSmokeTest(object): comment = soup.find(text="foobar") self.assertEqual(comment.__class__, Comment) + # The comment is properly integrated into the tree. + foo = soup.find(text="foo") + self.assertEqual(comment, foo.next_element) + baz = soup.find(text="baz") + self.assertEquals(comment, baz.previous_element) + def test_preserved_whitespace_in_pre_and_textarea(self): """Whitespace must be preserved in <pre> and <textarea> tags.""" self.assertSoupEquals("<pre> </pre>") @@ -523,6 +529,12 @@ class HTML5TreeBuilderSmokeTest(HTMLTreeBuilderSmokeTest): self.assertEqual(namespace, soup.math.namespace) self.assertEqual(namespace, soup.msqrt.namespace) + def test_xml_declaration_becomes_comment(self): + markup = '<?xml version="1.0" encoding="utf-8"?><html></html>' + soup = self.soup(markup) + self.assertTrue(isinstance(soup.contents[0], Comment)) + self.assertEqual(soup.contents[0], '?xml version="1.0" encoding="utf-8"?') + self.assertEqual("html", soup.contents[0].next_element.name) def skipIf(condition, reason): def nothing(test, *args, **kwargs): |