summaryrefslogtreecommitdiff
path: root/bs4/tests/test_tree.py
diff options
context:
space:
mode:
authorLeonard Richardson <leonardr@segfault.org>2019-01-06 18:49:34 -0500
committerLeonard Richardson <leonardr@segfault.org>2019-01-06 18:49:34 -0500
commit37475317c329d38b6dfa6061695035fcbce6b7d4 (patch)
treefeb4bb09875fb9823d35272775b5a5601adcd3c9 /bs4/tests/test_tree.py
parent047ccd22fe038813024d5d29b9d68dc5616edac8 (diff)
Fixed an incorrectly raised exception when inserting a tag before or
after an identical tag. [bug=1810692]
Diffstat (limited to 'bs4/tests/test_tree.py')
-rw-r--r--bs4/tests/test_tree.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/bs4/tests/test_tree.py b/bs4/tests/test_tree.py
index 2290558..6d79454 100644
--- a/bs4/tests/test_tree.py
+++ b/bs4/tests/test_tree.py
@@ -971,6 +971,10 @@ class TestTreeModification(SoupTest):
# Can't insert before if an element has no parent.
b.extract()
self.assertRaises(ValueError, b.insert_before, "nope")
+
+ # Can insert an identical element
+ soup = self.soup("<a>")
+ soup.a.insert_before(soup.new_tag("a"))
def test_insert_multiple_before(self):
soup = self.soup("<a>foo</a><b>bar</b>")
@@ -1000,6 +1004,10 @@ class TestTreeModification(SoupTest):
# Can't insert after if an element has no parent.
b.extract()
self.assertRaises(ValueError, b.insert_after, "nope")
+
+ # Can insert an identical element
+ soup = self.soup("<a>")
+ soup.a.insert_before(soup.new_tag("a"))
def test_insert_multiple_after(self):
soup = self.soup("<a>foo</a><b>bar</b>")