version 1.1.1.1, 2012/02/21 23:38:00
|
version 1.1.1.2, 2014/06/15 19:53:34
|
Line 3
|
Line 3
|
# this tests the basic APIs of the XmlTextReader interface |
# this tests the basic APIs of the XmlTextReader interface |
# |
# |
import libxml2 |
import libxml2 |
import StringIO |
|
import sys |
import sys |
|
try: |
|
import StringIO |
|
str_io = StringIO.StringIO |
|
except: |
|
import io |
|
str_io = io.StringIO |
|
|
# Memory debug specific |
# Memory debug specific |
libxml2.debugMemory(1) |
libxml2.debugMemory(1) |
|
|
def tst_reader(s): |
def tst_reader(s): |
f = StringIO.StringIO(s) | f = str_io(s) |
input = libxml2.inputBuffer(f) |
input = libxml2.inputBuffer(f) |
reader = input.newTextReader("tst") |
reader = input.newTextReader("tst") |
res = "" |
res = "" |
Line 32 expect="""1 (test) [None] 0
|
Line 37 expect="""1 (test) [None] 0
|
res = tst_reader("""<test><b/><c/></test>""") |
res = tst_reader("""<test><b/><c/></test>""") |
|
|
if res != expect: |
if res != expect: |
print "Did not get the expected error message:" | print("Did not get the expected error message:") |
print res | print(res) |
sys.exit(1) |
sys.exit(1) |
|
|
# Memory debug specific |
# Memory debug specific |
libxml2.cleanupParser() |
libxml2.cleanupParser() |
if libxml2.debugMemory(1) == 0: |
if libxml2.debugMemory(1) == 0: |
print "OK" | print("OK") |
else: |
else: |
print "Memory leak %d bytes" % (libxml2.debugMemory(1)) | print("Memory leak %d bytes" % (libxml2.debugMemory(1))) |
libxml2.dumpMemory() |
libxml2.dumpMemory() |