def test_remove_child(self): top = vmxml.find_first(self._dom, 'topelement') hello = list(vmxml.find_all(top, 'hello')) old = hello[1] vmxml.remove_child(top, old) updated_hello = list(vmxml.find_all(top, 'hello')) hello = hello[:1] + hello[2:] self.assertEqual(updated_hello, hello)
def test_find_all(self, start_tag, tag, number): dom = self._dom if start_tag is not None: dom = vmxml.find_first(self._dom, 'topelement') elements = vmxml.find_all(dom, tag) matches = [vmxml.tag(e) == tag for e in elements] self.assertTrue(all(matches)) self.assertEqual(len(matches), number)
def test_attributes(self, tag, index, result): element = list(vmxml.find_all(self._dom, tag))[index] self.assertEqual(vmxml.attributes(element), result)