VirtualBox

source: vbox/trunk/src/libs/libxml2-2.9.4/python/tests/resolver.py@ 65950

Last change on this file since 65950 was 65950, checked in by vboxsync, 8 years ago

libxml 2.9.4: fix export

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
File size: 857 bytes
Line 
1#!/usr/bin/python -u
2import sys
3import libxml2
4try:
5 import StringIO
6 str_io = StringIO.StringIO
7except:
8 import io
9 str_io = io.StringIO
10
11# Memory debug specific
12libxml2.debugMemory(1)
13
14def myResolver(URL, ID, ctxt):
15 return(str_io("<foo/>"))
16
17libxml2.setEntityLoader(myResolver)
18
19doc = libxml2.parseFile("doesnotexist.xml")
20root = doc.children
21if root.name != "foo":
22 print("root element name error")
23 sys.exit(1)
24doc.freeDoc()
25
26i = 0
27while i < 5000:
28 doc = libxml2.parseFile("doesnotexist.xml")
29 root = doc.children
30 if root.name != "foo":
31 print("root element name error")
32 sys.exit(1)
33 doc.freeDoc()
34 i = i + 1
35
36
37# Memory debug specific
38libxml2.cleanupParser()
39if libxml2.debugMemory(1) == 0:
40 print("OK")
41else:
42 print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
43 libxml2.dumpMemory()
44
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette