def test_xml_find3(self):
   tagList = ["<THU>", "<Team>", "<Bob>", "<John>", "<JiaJia>", "<Team>", "<Tim>", "<7>"]
   levelList = [1,2,3,3,2,3,4,4]
   searchList = ["<Team>", "<7>"]
   x = xml_find(tagList, levelList, searchList)
 #  print x
   self.assert_(x == [6])
 def test_xml_find_5 (self):
 	r = StringIO.StringIO(string_5)
 	w = StringIO.StringIO()
 	xml_find(r, w)
 	self.assert_( w.getvalue() == '1\n2\n\n1\n3\n\n2\n2\n8\n' )
 def test_xml_find_3 (self):
 	r = StringIO.StringIO(string_3)
 	w = StringIO.StringIO()
 	xml_find(r, w)
 	self.assert_( w.getvalue() == '2\n2\n8\n' )
 def test_xml_find_2 (self):
 	r = StringIO.StringIO(string_2)
 	w = StringIO.StringIO()
 	xml_find(r, w)
 	self.assert_( w.getvalue() == '1\n3\n' )
#!/lusr/bin/python

from XML import xml_find
from datetime import datetime
from sys import stdin, stdout, setrecursionlimit

# Set to true to display timing information
time = False

# Recursion limit is set to 1000 by default, which fails for
# very large XMLs. Increase it.
setrecursionlimit(100000)

# Call the main program and time it
t1 = datetime.now()
xml_find (stdin, stdout)
t2 = datetime.now()
if time:
    print str((t2-t1))
 def test_xml_find2(self):
   tagList = ["<THU>", "<Team>", "<Cooly>", "<JiaJia>", "<Team>", "<Cooly>", "<Amber>"]
   levelList = [1, 2, 3, 2, 3, 4, 4]
   searchList = ["<Team>", "<Cooly>"]
   x = xml_find(tagList, levelList, searchList)
   self.assert_(x == [2, 5])
 def test_xml_find1(self):
   tagList = ["<THU>", "<Team>", "<Cooly>"]
   levelList = [1, 2, 3]
   searchList = ["<Team>", "<Cooly>"]
   x = xml_find(tagList, levelList, searchList)
   self.assert_(x == [2])
Beispiel #8
0
 def test_find_3 (self) :
     v = xml_find(fromstring("<red><green><blue></blue><yellow></yellow></green></red>"), fromstring("<green><purple></purple></green>"))
     self.assertTrue(v == [])
Beispiel #9
0
 def test_find_1 (self) :
     v = xml_find(fromstring("<THU><Team><ACRush></ACRush><Jelly></Jelly><Cooly></Cooly></Team><JiaJia><Team><Ahyangyi></Ahyangyi><Dragon></Dragon><Cooly><Amber></Amber></Cooly></Team></JiaJia></THU>"), fromstring("<Team><Cooly></Cooly></Team>"))
     self.assertTrue(v == [2,7])