tst.py 582 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/python -u
  2. import sys
  3. import libxml2
  4. # Memory debug specific
  5. libxml2.debugMemory(1)
  6. doc = libxml2.parseFile("tst.xml")
  7. if doc.name != "tst.xml":
  8. print "doc.name failed"
  9. sys.exit(1)
  10. root = doc.children
  11. if root.name != "doc":
  12. print "root.name failed"
  13. sys.exit(1)
  14. child = root.children
  15. if child.name != "foo":
  16. print "child.name failed"
  17. sys.exit(1)
  18. doc.freeDoc()
  19. # Memory debug specific
  20. libxml2.cleanupParser()
  21. if libxml2.debugMemory(1) == 0:
  22. print "OK"
  23. else:
  24. print "Memory leak %d bytes" % (libxml2.debugMemory(1))
  25. libxml2.dumpMemory()