diff options
-rw-r--r-- | CHANGELOG | 6 | ||||
-rw-r--r-- | tests/test_tree.py | 9 |
2 files changed, 12 insertions, 3 deletions
@@ -59,9 +59,9 @@ The value of a.string used to be None, and now it's "foo". Beautiful Soup's handling of empty-element tags (aka self-closing tags) has been improved, especially when parsing XML. Previously you -had to explicitly specify a list of empty-element tags. You can still -do that, but if you don't, Beautiful Soup now considers any empty tag -to be an empty-element tag. +had to explicitly specify a list of empty-element tags when parsing +XML. You can still do that, but if you don't, Beautiful Soup now +considers any empty tag to be an empty-element tag. The determination of empty-element-ness is now made at runtime rather than parse time. If you add a child to an empty-element tag, it stops diff --git a/tests/test_tree.py b/tests/test_tree.py index 191f614..40643dc 100644 --- a/tests/test_tree.py +++ b/tests/test_tree.py @@ -620,6 +620,15 @@ class TestTreeModification(SoupTest): self.assertEqual(the.next, c_tag) self.assertEqual(c_tag.previous, the) + def test_insert_works_on_empty_element_tag(self): + # This is a little strange, since most HTML parsers don't allow + # markup like this to come through. But in general, we don't + # know what the parser would or wouldn't have allowed, so + # I'm letting this succeed for now. + soup = self.soup("<br />") + soup.br.insert(1, "Contents") + self.assertEquals(str(soup.br), "<br>Contents</br>") + def test_replace_with(self): soup = self.soup( "<p>There's <b>no</b> business like <b>show</b> business</p>") |