def test_eval_3 (self) : # Query tree does not exist in source tree a = fromstring("<a><b><c></c><d></d></b></a>") b = fromstring("<b><e></e></b>") v = xmleval(a,b) print (str(v)) self.assertTrue(v == [0])
def test_eval_2 (self) : # Query tree have more than 2 layers a = fromstring("<a><b><c></c><d><f></f></d></b></a>") b = fromstring("<b><d><f></f></d></b>") v = xmleval(a,b) print (str(v)) self.assertTrue(v == [1,2])
def test_eval_5 (self) : # children in query tree have siblings a = fromstring("<a><c><f></f><h></h></c><c><d><e></e></d><f></f><h></h></c>"\ +"<g><h><c><f></f><h><i></i></h></c></h></g></a>") b = fromstring("<c><f></f><h></h></c>") v = xmleval(a,b) print (str(v)) self.assertTrue(v == [3,2,5,12])
def test_eval_6 (self) : # query tree is on top root a = fromstring("<a><c><f></f><h></h></c><c><d><e></e></d><f></f><h></h></c>"\ +"<g><h><c><f></f><h><i></i></h></c></h></g></a>") b = fromstring("<a><c><f></f></c></a>") v = xmleval(a,b) print (str(v)) self.assertTrue(v == [1,1])
def test_eval_1 (self) : # Test source string from SPOJ a = fromstring("<THU><Team><ACRush></ACRush><Jelly></Jelly><Cooly></Cooly></Team>" \ +"<JiaJia><Team><Ahyangyi></Ahyangyi><Dragon></Dragon>"\ +"<Cooly><Amber></Amber></Cooly></Team></JiaJia></THU>") b = fromstring("<Team><Cooly></Cooly></Team>") v = xmleval(a,b) print (str(v)) self.assertTrue(v == [2,2,7])
def test_eval_4 (self) : a = fromstring("<a><c><f></f></c><c><d><e></e></d><f></f></c><g><h><c><f></f></c></h></g></a>") b = fromstring("<c><f></f></c>") v = xmleval(a,b) print (str(v)) self.assertTrue(v == [3,2,4,10])