Beispiel #1
0
 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)  
Beispiel #2
0
 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)                
Beispiel #3
0
 def test_count_tree3 (self) :
     input1 = "<Team><Cooly><Green><Red></Red></Green></Cooly><ACRush></ACRush><Jelly></Jelly></Team>"
     all_tree = []
     tree = fromstring(input1)
     count_tree(tree, all_tree)
     self.assertTrue (len(all_tree) == 6)
Beispiel #4
0
 def test_count_tree2 (self) :
     input1 = "<Team><Cooly></Cooly></Team>"
     all_tree = []
     tree = fromstring(input1)
     count_tree(tree, all_tree)
     self.assertTrue (len(all_tree) == 2)