(root)/
libxml2-2.12.3/
python/
tests/
push.py
       1  #!/usr/bin/env python3
       2  import sys
       3  import setup_test
       4  import libxml2
       5  
       6  # Memory debug specific
       7  libxml2.debugMemory(1)
       8  
       9  ctxt = libxml2.createPushParser(None, "<foo", 4, "test.xml")
      10  ctxt.parseChunk("/>", 2, 1)
      11  doc = ctxt.doc()
      12  ctxt=None
      13  if doc.name != "test.xml":
      14      print("document name error")
      15      sys.exit(1)
      16  root = doc.children
      17  if root.name != "foo":
      18      print("root element name error")
      19      sys.exit(1)
      20  doc.freeDoc()
      21  i = 10000
      22  while i > 0:
      23      ctxt = libxml2.createPushParser(None, "<foo", 4, "test.xml")
      24      ctxt.parseChunk("/>", 2, 1)
      25      doc = ctxt.doc()
      26      doc.freeDoc()
      27      i = i -1
      28  ctxt=None
      29  
      30  # Memory debug specific
      31  libxml2.cleanupParser()
      32  if libxml2.debugMemory(1) == 0:
      33      print("OK")
      34  else:
      35      print("Memory leak %d bytes" % (libxml2.debugMemory(1)))