summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonard Richardson <leonard.richardson@canonical.com>2011-02-20 09:54:22 -0500
committerLeonard Richardson <leonard.richardson@canonical.com>2011-02-20 09:54:22 -0500
commit9f437ea591aeaf16d593350baf081315e56a8b73 (patch)
tree116edd8c1d9a7cf6348f784162fd2291608833c2
parent7dec14806011343d3460a3fa34d7cf88799e8f4c (diff)
Added a test showing weird behavior when you .insert contents into an empty-element tag.
-rw-r--r--CHANGELOG6
-rw-r--r--tests/test_tree.py9
2 files changed, 12 insertions, 3 deletions
diff --git a/CHANGELOG b/CHANGELOG
index ef05813..96a9ed4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -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>")