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

1.1       misho       1: #!/usr/bin/python -u
                      2: #
                      3: # This test exercise the redirection of error messages with a
                      4: # functions defined in Python.
                      5: #
                      6: import sys
                      7: import libxml2
                      8: 
                      9: # Memory debug specific
                     10: libxml2.debugMemory(1)
                     11: 
                     12: expect='--> I/O --> warning : --> failed to load external entity "missing.xml"\n'
                     13: err=""
                     14: def callback(ctx, str):
                     15:      global err
                     16: 
                     17:      err = err + "%s %s" % (ctx, str)
                     18: 
                     19: got_exc = 0
                     20: libxml2.registerErrorHandler(callback, "-->")
                     21: try:
                     22:     doc = libxml2.parseFile("missing.xml")
                     23: except libxml2.parserError:
                     24:     got_exc = 1
                     25: 
                     26: if got_exc == 0:
1.1.1.2 ! misho      27:     print("Failed to get a parser exception")
1.1       misho      28:     sys.exit(1)
                     29: 
                     30: if err != expect:
1.1.1.2 ! misho      31:     print("error")
        !            32:     print("received %s" %(err))
        !            33:     print("expected %s" %(expect))
1.1       misho      34:     sys.exit(1)
                     35: 
                     36: i = 10000
                     37: while i > 0:
                     38:     try:
                     39:         doc = libxml2.parseFile("missing.xml")
                     40:     except libxml2.parserError:
                     41:         got_exc = 1
                     42:     err = ""
                     43:     i = i - 1
                     44: 
                     45: # Memory debug specific
                     46: libxml2.cleanupParser()
                     47: if libxml2.debugMemory(1) == 0:
1.1.1.2 ! misho      48:     print("OK")
1.1       misho      49: else:
1.1.1.2 ! misho      50:     print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
1.1       misho      51:     libxml2.dumpMemory()

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