~ubuntu-branches/ubuntu/wily/opencollada/wily-proposed

« back to all changes in this revision

Viewing changes to Externals/LibXML/python/tests/resolver.py

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2015-05-14 17:23:27 UTC
  • Revision ID: package-import@ubuntu.com-20150514172327-f862u8envms01fra
Tags: upstream-0.1.0~20140703.ddf8f47+dfsg1
ImportĀ upstreamĀ versionĀ 0.1.0~20140703.ddf8f47+dfsg1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python -u
 
2
import sys
 
3
import libxml2
 
4
import StringIO
 
5
 
 
6
# Memory debug specific
 
7
libxml2.debugMemory(1)
 
8
 
 
9
def myResolver(URL, ID, ctxt):
 
10
    return(StringIO.StringIO("<foo/>"))
 
11
 
 
12
libxml2.setEntityLoader(myResolver)
 
13
 
 
14
doc = libxml2.parseFile("doesnotexist.xml")
 
15
root = doc.children
 
16
if root.name != "foo":
 
17
    print "root element name error"
 
18
    sys.exit(1)
 
19
doc.freeDoc()
 
20
 
 
21
i = 0
 
22
while i < 5000:
 
23
    doc = libxml2.parseFile("doesnotexist.xml")
 
24
    root = doc.children
 
25
    if root.name != "foo":
 
26
        print "root element name error"
 
27
        sys.exit(1)
 
28
    doc.freeDoc()
 
29
    i = i + 1
 
30
 
 
31
 
 
32
# Memory debug specific
 
33
libxml2.cleanupParser()
 
34
if libxml2.debugMemory(1) == 0:
 
35
    print "OK"
 
36
else:
 
37
    print "Memory leak %d bytes" % (libxml2.debugMemory(1))
 
38
    libxml2.dumpMemory()
 
39