Diff for /embedaddon/libxml2/python/tests/reader6.py between versions 1.1 and 1.1.1.2

version 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 entities substitutions with the XmlTextReader interface  # this tests the entities substitutions with the XmlTextReader interface
 #  #
 import sys  import sys
 import StringIO  
 import libxml2  import libxml2
   try:
       import StringIO
       str_io = StringIO.StringIO
   except:
       import io
       str_io = io.StringIO
   
 schema="""<element name="foo" xmlns="http://relaxng.org/ns/structure/1.0"  schema="""<element name="foo" xmlns="http://relaxng.org/ns/structure/1.0"
          datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">           datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
Line 41  docstr="""<foo> Line 46  docstr="""<foo>
 <item>100</item>  <item>100</item>
 </foo>"""  </foo>"""
   
f = StringIO.StringIO(docstr)f = str_io(docstr)
 input = libxml2.inputBuffer(f)  input = libxml2.inputBuffer(f)
 reader = input.newTextReader("correct")  reader = input.newTextReader("correct")
 reader.RelaxNGSetSchema(rngs)  reader.RelaxNGSetSchema(rngs)
Line 50  while ret == 1: Line 55  while ret == 1:
     ret = reader.Read()      ret = reader.Read()
   
 if ret != 0:  if ret != 0:
    print "Error parsing the document"    print("Error parsing the document")
     sys.exit(1)      sys.exit(1)
   
 if reader.IsValid() != 1:  if reader.IsValid() != 1:
    print "Document failed to validate"    print("Document failed to validate")
     sys.exit(1)      sys.exit(1)
   
 #  #
Line 84  def callback(ctx, str): Line 89  def callback(ctx, str):
     err = err + "%s" % (str)      err = err + "%s" % (str)
 libxml2.registerErrorHandler(callback, "")  libxml2.registerErrorHandler(callback, "")
   
f = StringIO.StringIO(docstr)f = str_io(docstr)
 input = libxml2.inputBuffer(f)  input = libxml2.inputBuffer(f)
 reader = input.newTextReader("error")  reader = input.newTextReader("error")
 reader.RelaxNGSetSchema(rngs)  reader.RelaxNGSetSchema(rngs)
Line 93  while ret == 1: Line 98  while ret == 1:
     ret = reader.Read()      ret = reader.Read()
   
 if ret != 0:  if ret != 0:
    print "Error parsing the document"    print("Error parsing the document")
     sys.exit(1)      sys.exit(1)
   
 if reader.IsValid() != 0:  if reader.IsValid() != 0:
    print "Document failed to detect the validation error"    print("Document failed to detect the validation error")
     sys.exit(1)      sys.exit(1)
   
 if err != expect:  if err != expect:
    print "Did not get the expected error message:"    print("Did not get the expected error message:")
    print err    print(err)
     sys.exit(1)      sys.exit(1)
   
 #  #
Line 117  libxml2.relaxNGCleanupTypes() Line 122  libxml2.relaxNGCleanupTypes()
 # 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()

Removed from v.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>