def test_matching_pats(self) : tree = fromstring("<Team><ACRush></ACRush><Jelly></Jelly><Cooly></Cooly></Team>") query = fromstring("<Team><Cooly></Cooly></Team>") root_query = fromstring("<Team><Cooly></Cooly></Team>") all_tree = [] count_tree(tree, all_tree) count_query(root_query) traverse_tree(tree, query, root_query) final = matching_pats(XML.count_pat, all_tree) self.assertTrue (type(final) == list) self.assertTrue (type(XML.count_pat) == list) self.assertTrue (type(i) == Element for i in XML.count_pat) self.assertTrue (type(all_tree) == list) self.assertTrue (type(i) == Element for i in all_tree)
def test_matching_pats3(self) : # testing case where there is new lines tree = fromstring("<red>\n<green>\n</green>\n</red>\n") query = fromstring("<yellow>\n</yellow>\n\n") root_query = fromstring("<yellow>\n</yellow>\n\n") all_tree = [] count_tree(tree, all_tree) count_query(root_query) traverse_tree(tree, query, root_query) final = matching_pats(XML.count_pat, all_tree) self.assertTrue (type(final) == list) self.assertTrue (len(final) == 0) self.assertTrue (type(XML.count_pat) == list) self.assertTrue (type(i) == Element for i in XML.count_pat) self.assertTrue (type(all_tree) == list) self.assertTrue (type(i) == Element for i in all_tree)