diff options
author | Leonard Richardson <leonard.richardson@canonical.com> | 2012-02-09 09:22:21 -0500 |
---|---|---|
committer | Leonard Richardson <leonard.richardson@canonical.com> | 2012-02-09 09:22:21 -0500 |
commit | c199d176f1ebb4289428e1ba8a939b2cd1b55218 (patch) | |
tree | bf26b8a753f1acdee884ea08597a7d58f9a4afda /bs4/tests/test_tree.py | |
parent | ec3d55d62ddf86ba220b8acdafa5a33a74acaebb (diff) |
Fixed a bug that wrecked the tree if you replaced an element with an empty string. [bug=728697]
Diffstat (limited to 'bs4/tests/test_tree.py')
-rw-r--r-- | bs4/tests/test_tree.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/bs4/tests/test_tree.py b/bs4/tests/test_tree.py index 6ff87fc..511d907 100644 --- a/bs4/tests/test_tree.py +++ b/bs4/tests/test_tree.py @@ -664,6 +664,21 @@ class TestTreeModification(SoupTest): soup = self.soup(text) self.assertRaises(ValueError, soup.a.insert, 0, soup.a) + def test_replace_with_maintains_next_element_throughout(self): + soup = self.soup('<p><a>one</a><b>three</b></p>') + a = soup.a + b = a.contents[0] + # Make it so the <a> tag has two text children. + a.insert(1, "two") + + # Now replace each one with the empty string. + left, right = a.contents + left.replaceWith('') + right.replaceWith('') + + # The <b> tag is still connected to the tree. + self.assertEqual("three", soup.b.string) + def test_replace_final_node(self): soup = self.soup("<b>Argh!</b>") soup.find(text="Argh!").replace_with("Hooray!") |