def test_find_pairs_3 (self) : s = "<xml><parent1><child1><grandchild1></grandchild1></child1></parent1><parent2></parent2></xml>" a = xml_find_pairs(s) i, j = a self.assertTrue(type(i) is Element) self.assertTrue(type(j) is Element) self.assertTrue(xml_traverse(i) == xml_traverse(fromstring("<parent1><child1><grandchild1></grandchild1></child1></parent1>"))) self.assertTrue(xml_traverse(j) == xml_traverse(fromstring("<parent2></parent2>")))
def test_xml_traverse_3(self) : r = StringIO.StringIO("<THU>\n</THU>\n<THU></THU>\n") a = xml_read(r) root = a[0] root_query = a[1] occurrences = [0] id_list = [] query_list = [root_query] element_list = [root] first_match = [None] id_map = {root : 1} id_tracker = [2] id_helper(root, id_tracker, id_map) xml_traverse (element_list, query_list, root_query, occurrences, id_list, first_match, id_map) self.assert_(occurrences[0] == 1) self.assert_(id_list == [1])
def test_xml_traverse_1(self) : r = StringIO.StringIO("<THU>\n<Team>\n<ACRush></ACRush>\n<Jelly></Jelly>\n<Cooly></Cooly>\n</Team>\n<JiaJia>\n<Team>\n<Ahyangyi></Ahyangyi>\n<Dragon></Dragon>\n<Cooly><Amber></Amber></Cooly>\n</Team>\n</JiaJia>\n</THU>\n<Team><Cooly></Cooly></Team>\n") a = xml_read(r) root = a[0] root_query = a[1] occurrences = [0] id_list = [] query_list = [root_query] element_list = [root] first_match = [None] id_map = {root : 1} id_tracker = [2] id_helper(root, id_tracker, id_map) xml_traverse (element_list, query_list, root_query, occurrences, id_list, first_match, id_map) self.assert_(occurrences[0] == 2) self.assert_(id_list == [2, 7])
def test_traverse_3 (self) : s = "<parent><child><grandchild></grandchild></child></parent>" x = fromstring(s) l = xml_traverse(x) self.assertTrue(l != "") self.assertTrue(l == "<parent><child><grandchild></grandchild></child></parent>")
def test_traverse_2 (self) : s = "<parent></parent>" x = fromstring(s) l = xml_traverse(x) self.assertTrue(l != "") self.assertTrue(l == "<parent></parent>")