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

Method test_consecutive_text_nodes

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

Source from the content-addressed store, hash-verified

834 self.assertEqual(new_text.next_element, None)
835
836 def test_consecutive_text_nodes(self):
837 # A builder should never create two consecutive text nodes,
838 # but if you insert one next to another, Beautiful Soup will
839 # handle it correctly.
840 soup = self.soup("<a><b>Argh!</b><c></c></a>")
841 soup.b.insert(1, "Hooray!")
842
843 self.assertEqual(
844 soup.decode(), self.document_for(
845 "<a><b>Argh!Hooray!</b><c></c></a>"))
846
847 new_text = soup.find(text="Hooray!")
848 self.assertEqual(new_text.previous_element, "Argh!")
849 self.assertEqual(new_text.previous_element.next_element, new_text)
850
851 self.assertEqual(new_text.previous_sibling, "Argh!")
852 self.assertEqual(new_text.previous_sibling.next_sibling, new_text)
853
854 self.assertEqual(new_text.next_sibling, None)
855 self.assertEqual(new_text.next_element, soup.c)
856
857 def test_insert_string(self):
858 soup = self.soup("<a></a>")

Callers

nothing calls this directly

Calls 5

soupMethod · 0.45
insertMethod · 0.45
decodeMethod · 0.45
document_forMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected