def tearDown(self):
        libxml2.cleanupParser()
        if libxml2.debugMemory(1) != 0:
            libxml2.dumpMemory() 
            self.fail("Memory leak %d bytes" % (libxml2.debugMemory(1),))
	else:
	    print "OK"
Beispiel #2
0
 def tearDown(self):
     libxml2.cleanupParser()
     if libxml2.debugMemory(1) != 0:
         libxml2.dumpMemory()
         self.fail("Memory leak %d bytes" % (libxml2.debugMemory(1), ))
     else:
         print("OK")
Beispiel #3
0
 def __del__(self):
     if self.doc != None:
         self.doc.freeDoc()
     libxml2.cleanupParser()
     if libxml2.debugMemory(1) != 0:
         print "Memory leak %d bytes" % (libxml2.debugMemory(1))
         libxml2.dumpMemory()
Beispiel #4
0
    def stop(self):
        sMessage = None
        # Memory debug specific

        libxml2.cleanupParser()
        if libxml2.debugMemory(1) != 0:
            sMessage = _("LIBXML2 Memory leak %d bytes") %\
                       (libxml2.debugMemory(1))
        libxml2.dumpMemory()
        return sMessage
Beispiel #5
0
def main():
    o = OptionParser()
    o.add_option("-s", "--safe",
                 dest="safe",
                 action="store_true",
                 help="Safe mode (ignore configuration)")
    o.add_option("-c", "--config",
                 dest="config",
                 help="Use alternate configuration directory")
    o.add_option("-p", "--profile",
                 dest="profile",
                 action="store_true",
                 help="Enable profiling")
    (opts, args) = o.parse_args()

    from d_rats import platform

    if opts.config:
        platform.get_platform(opts.config)

    from d_rats import mainapp

    install_excepthook()

    import libxml2

    libxml2.debugMemory(1)

    app = mainapp.MainApp(safe=opts.safe)
    if opts.profile:
        import cProfile
        cProfile.run('app.main()')
    else:
        rc = app.main()
        uninstall_excepthook()
        libxml2.dumpMemory()
        sys.exit(rc)
Beispiel #6
0
ctxt_valid.setValidityErrorHandler(e.handler, e.handler, ARG)

# Test valid document
doc = libxml2.parseDoc(valid)
ret = doc.schemaValidateDoc(ctxt_valid)
if ret != 0 or e.errors:
    print("error doing schema validation")
    sys.exit(1)
doc.freeDoc()

# Test invalid document
doc = libxml2.parseDoc(invalid)
ret = doc.schemaValidateDoc(ctxt_valid)
if ret == 0 or not e.errors:
    print("Error: document supposer to be schema invalid")
    sys.exit(1)
doc.freeDoc()

del ctxt_parser
del ctxt_schema
del ctxt_valid
libxml2.schemaCleanupTypes()

# Memory debug specific
libxml2.cleanupParser()
if libxml2.debugMemory(1) == 0:
    print("OK")
else:
    print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
    libxml2.dumpMemory()
Beispiel #7
0
    return None

libxml2.setEntityLoader(myResolver)

input = libxml2.inputBuffer(str_io(s))
reader = input.newTextReader("test3")
reader.SetParserProp(libxml2.PARSER_SUBST_ENTITIES,1)
while reader.Read() == 1:
    res = res + "%s %s %d %d\n" % (reader.NodeType(),reader.Name(),
                                   reader.Depth(),reader.IsEmptyElement())

if res != expect:
    print("test3 failed: unexpected output")
    print(res)
    sys.exit(1)

#
# cleanup
#
del f
del input
del reader

# Memory debug specific
libxml2.cleanupParser()
if libxml2.debugMemory(1) == 0:
    print("OK")
else:
    print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
    libxml2.dumpMemory()