def test_xml_check_4 (self) : # pattern includes grandchild and false starting point s = "<A><B><E></E><D></D><A></A></B><E><E></E></E></A>" c = fromstring(s) t = "<A><B><E></E></B></A>" p = fromstring(t) r = xml_check(c, p) self.assertTrue(r == True) second_potential = c.find("B").find("A") r = xml_check(second_potential, p) self.assertTrue(r == False)
def test_xml_check_2 (self) : s = "<A><B><C></C></B><B><E></E></B></A>" c = fromstring(s) t = "<B><C></C></B>" p = fromstring(t) first_potential = list(c)[0] second_potential = list(c)[1] potentials = [first_potential, second_potential] r = xml_check(potentials[0], p) self.assertTrue(r == True) r = xml_check(potentials[1], p) self.assertTrue(r == False)
def test_xml_check (self) : s = "<A><B><C></C><D></D></B></A>" c = fromstring(s) t = "<A><B></B></A>" p = fromstring(t) r = xml_check(c, p) self.assertTrue(r == True)
def test_xml_check_5 (self) : s = "<A><B><C></C><A></A></B><A><B><C></C></B></A></A>" c = fromstring(s) t = "<A><B><C></C></B></A>" p = fromstring(t) first_potential = list(c)[0] F = xml_check(first_potential, p) self.assertTrue(F == False)