Annotation of embedaddon/libxml2/python/tests/resolver.py, revision 1.1.1.2
1.1 misho 1: #!/usr/bin/python -u
2: import sys
3: import libxml2
1.1.1.2 ! misho 4: try:
! 5: import StringIO
! 6: str_io = StringIO.StringIO
! 7: except:
! 8: import io
! 9: str_io = io.StringIO
1.1 misho 10:
11: # Memory debug specific
12: libxml2.debugMemory(1)
13:
14: def myResolver(URL, ID, ctxt):
1.1.1.2 ! misho 15: return(str_io("<foo/>"))
1.1 misho 16:
17: libxml2.setEntityLoader(myResolver)
18:
19: doc = libxml2.parseFile("doesnotexist.xml")
20: root = doc.children
21: if root.name != "foo":
1.1.1.2 ! misho 22: print("root element name error")
1.1 misho 23: sys.exit(1)
24: doc.freeDoc()
25:
26: i = 0
27: while i < 5000:
28: doc = libxml2.parseFile("doesnotexist.xml")
29: root = doc.children
30: if root.name != "foo":
1.1.1.2 ! misho 31: print("root element name error")
1.1 misho 32: sys.exit(1)
33: doc.freeDoc()
34: i = i + 1
35:
36:
37: # Memory debug specific
38: libxml2.cleanupParser()
39: if libxml2.debugMemory(1) == 0:
1.1.1.2 ! misho 40: print("OK")
1.1 misho 41: else:
1.1.1.2 ! misho 42: print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
1.1 misho 43: libxml2.dumpMemory()
44:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>