def test_without_tail(self): "Testing remove_node_keeping_tail without tail" xml = b'''<parent><target/></parent>''' tree = lxml.etree.parse(BytesIO(xml)) target = tree.getroot()[0] remove_node_keeping_tail(target) self.assertEqual(lxml.etree.tostring(tree), b'''<parent/>''')
def test_with_tail_and_previous_tail(self): "Testing remove_node_keeping_tail with tail and previous tail" xml = b'''<parent><previous/>tail<target/>tail</parent>''' tree = lxml.etree.parse(BytesIO(xml)) target = tree.getroot()[1] remove_node_keeping_tail(target) self.assertEqual(lxml.etree.tostring(tree), b'''<parent><previous/>tailtail</parent>''')
def test_with_tail_and_parent_text(self): "Testing remove_node_keeping_tail with tail and parent text" xml = b'''<parent>text<target/>tail</parent>''' tree = lxml.etree.parse(BytesIO(xml)) target = tree.getroot()[0] remove_node_keeping_tail(target) self.assertEqual(lxml.etree.tostring(tree), b'''<parent>texttail</parent>''')