MCPcopy
hub / github.com/csev/py4e / test_replace_with

Method test_replace_with

code3/bs4/tests/test_tree.py:954–967  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

952 self.assertRaises(ValueError, tag.insert_before, tag)
953
954 def test_replace_with(self):
955 soup = self.soup(
956 "<p>There's <b>no</b> business like <b>show</b> business</p>")
957 no, show = soup.find_all('b')
958 show.replace_with(no)
959 self.assertEqual(
960 soup.decode(),
961 self.document_for(
962 "<p>There's business like <b>no</b> business</p>"))
963
964 self.assertEqual(show.parent, None)
965 self.assertEqual(no.parent, soup.p)
966 self.assertEqual(no.next_element, "no")
967 self.assertEqual(no.next_sibling, " business")
968
969 def test_replace_first_child(self):
970 data = "<a><b></b><c></c></a>"

Callers

nothing calls this directly

Calls 5

soupMethod · 0.45
find_allMethod · 0.45
replace_withMethod · 0.45
decodeMethod · 0.45
document_forMethod · 0.45

Tested by

no test coverage detected