def test_compare_2 (self) :
        """
        finds one match at the 2nd element
        """

	tag_list = []

	#mainTree
	tag_list.append("<Z>")
	tag_list.append("<A>")
	tag_list.append("<C>")
	tag_list.append("<D>")
	tag_list.append("</D>")
	tag_list.append("<E>")
	tag_list.append("</E>")
	tag_list.append("</C>")
	tag_list.append("</A>")
	tag_list.append("</Z>")

	#keyTree
	tag_list.append("<A>")
	tag_list.append("<C>")
	tag_list.append("<D>")
	tag_list.append("</D>")
	tag_list.append("</C>")
	tag_list.append("</A>")

	tree_list = []
	


	xml_populate_trees(tag_list, tree_list)
	
	matches = []



	xml_compare(tree_list[0], tree_list[1], matches)

	self.assert_(len(matches) == 1)
	self.assert_(matches[0] == 2)
    def test_compare_3 (self) :
        """
        Finds a key with two siblings
        """

	tag_list = []

	#mainTree
	tag_list.append("<A>")
	tag_list.append("<Very>")
	tag_list.append("<Bad>")
	tag_list.append("</Bad>")
	tag_list.append("<Story>")
	tag_list.append("</Story>")
	tag_list.append("</Very>")
	tag_list.append("</A>")

	#keyTree
	tag_list.append("<Very>")
	tag_list.append("<Bad>")
	tag_list.append("</Bad>")
	tag_list.append("<Story>")
	tag_list.append("</Story>")
	tag_list.append("</Very>")

	tree_list = []
	

	xml_populate_trees(tag_list, tree_list)
	
	matches = []


	xml_compare(tree_list[0], tree_list[1], matches)



	self.assert_(len(matches) == 1)
	self.assert_(matches[0] == 2)
Пример #3
0
 def test_compare_1(self):
     x = fromstring('<xml><THU><Team><ACRush></ACRush><Jelly></Jelly><Cooly></Cooly></Team><JiaJia><Team><Ahyangyi></Ahyangyi><Dragon></Dragon><Cooly><Amber></Amber></Cooly></Team></JiaJia></THU>\n<Team><Cooly></Cooly></Team></xml>')
     a = x[0][0]
     b = x[1]
     v = xml_compare(a,b)
     self.assertTrue(v == None)
Пример #4
0
 def test_compare_3 (self) :
     a = [fromstring("<apple><apple></apple><orange><apple></apple></orange></apple>"), fromstring("<apple></apple>")]
     i,j = a
     b = xml_compare(i, j)
     self.assertTrue(b == True)
Пример #5
0
 def test_compare_2 (self) :
     a = [fromstring("<apple><apple></apple><orange><peach><orange><peach></peach></orange></peach></orange><orange><peach></peach></orange></apple>"), fromstring("<orange><apple></apple></orange>")]
     i,j = a
     b = xml_compare(i, j)
     self.assertTrue(b == False)
Пример #6
0
 def test_compare_1 (self) :
     a = [fromstring("<parent1><child1><grandchild1></grandchild1></child1></parent1>"), fromstring("<child1><grandchild1></grandchild1></child1>")]
     i,j = a
     b = xml_compare(i, j)
     self.assertTrue(b == False)