Annotation of embedaddon/libxml2/python/tests/build.py, revision 1.1.1.2

1.1       misho       1: #!/usr/bin/python -u
                      2: import libxml2
                      3: import sys
                      4: 
                      5: # Memory debug specific
                      6: libxml2.debugMemory(1)
                      7: 
                      8: doc = libxml2.newDoc("1.0")
                      9: comment = doc.newDocComment("This is a generated document")
                     10: doc.addChild(comment)
                     11: pi = libxml2.newPI("test", "PI content")
                     12: doc.addChild(pi)
                     13: root = doc.newChild(None, "doc", None)
                     14: ns = root.newNs("http://example.com/doc", "my")
                     15: root.setNs(ns)
                     16: elem = root.newChild(None, "foo", "bar")
                     17: elem.setBase("http://example.com/imgs")
                     18: elem.setProp("img", "image.gif")
                     19: doc.saveFile("tmp.xml")
                     20: doc.freeDoc()
                     21: 
                     22: doc = libxml2.parseFile("tmp.xml")
                     23: comment = doc.children
                     24: if comment.type != "comment" or \
                     25:    comment.content != "This is a generated document":
1.1.1.2 ! misho      26:    print("error rereading comment")
1.1       misho      27:    sys.exit(1)
                     28: pi = comment.next
                     29: if pi.type != "pi" or pi.name != "test" or pi.content != "PI content":
1.1.1.2 ! misho      30:    print("error rereading PI")
1.1       misho      31:    sys.exit(1)
                     32: root = pi.next
                     33: if root.name != "doc":
1.1.1.2 ! misho      34:    print("error rereading root")
1.1       misho      35:    sys.exit(1)
                     36: ns = root.ns()
                     37: if ns.name != "my" or ns.content != "http://example.com/doc":
1.1.1.2 ! misho      38:    print("error rereading namespace")
1.1       misho      39:    sys.exit(1)
                     40: elem = root.children
                     41: if elem.name != "foo":
1.1.1.2 ! misho      42:    print("error rereading elem")
1.1       misho      43:    sys.exit(1)
                     44: if elem.getBase(None) != "http://example.com/imgs":
1.1.1.2 ! misho      45:    print("error rereading base")
1.1       misho      46:    sys.exit(1)
                     47: if elem.prop("img") != "image.gif":
1.1.1.2 ! misho      48:    print("error rereading property")
1.1       misho      49:    sys.exit(1)
                     50: 
                     51: doc.freeDoc()
                     52: 
                     53: # Memory debug specific
                     54: libxml2.cleanupParser()
                     55: if libxml2.debugMemory(1) == 0:
1.1.1.2 ! misho      56:     print("OK")
1.1       misho      57: else:
1.1.1.2 ! misho      58:     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
1.1       misho      59:     libxml2.dumpMemory()

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