def assert_no_dangling_Cclasses(doassert=None):
    global CheckForDanglingClasses
    global WorstDanglingCount
    sys._clear_type_cache()
    if doassert is None:
        doassert = AssertOnDanglingClasses
    CMAinit.uninit()
    gc.collect()  # For good measure...
    count = proj_class_live_object_count()
    #print >>sys.stderr, "CHECKING FOR DANGLING CLASSES (%d)..." % count
    # Avoid cluttering the output up with redundant messages...
    if count > WorstDanglingCount and CheckForDanglingClasses:
        WorstDanglingCount = count
        if doassert:
            print >> sys.stderr, 'STARTING OBJECT DUMP'
            print 'stdout STARTING OBJECT DUMP'
            dump_c_objects()
            print >> sys.stderr, 'OBJECT DUMP COMPLETE'
            print 'stdout OBJECT DUMP COMPLETE'
            raise AssertionError("Dangling C-class objects - %d still around" %
                                 count)
        else:
            print >> sys.stderr, (
                "*****ERROR: Dangling C-class objects - %d still around" %
                count)
Exemple #2
0
 def cleanio(self):
     if TestIO.mainloop is not None:
         TestIO.mainloop.quit()
     if self.pipe_read >= 0:
         os.close(self.pipe_read)
         self.pipe_read = -1
     TestIO.mainloop = None
     # Note that this having to do this implies that our I/O object persists
     # longer than I would have expected...
     # Is this because uninit needs to be done as part of the test instead of
     # as part of the cleanup action?
     del self.inframes
     del self.packetswritten
     del self.config
     self.timeout = None
     if CMAdb.store:
         CMAdb.store.abort()
         CMAdb.store.weaknoderefs = {}
         CMAdb.store = None
     CMAinit.uninit()
 def cleanio(self):
     if TestIO.mainloop is not None:
         TestIO.mainloop.quit()
     if self.pipe_read >= 0:
         os.close(self.pipe_read)
         self.pipe_read = -1
     TestIO.mainloop = None
     # Note that this having to do this implies that our I/O object persists
     # longer than I would have expected...
     # Is this because uninit needs to be done as part of the test instead of
     # as part of the cleanup action?
     del self.inframes
     del self.packetswritten
     del self.config
     self.timeout = None
     if CMAdb.store:
         CMAdb.store.abort()
         CMAdb.store.weaknoderefs = {}
         CMAdb.store = None
     CMAinit.uninit()
def assert_no_dangling_Cclasses(doassert=None):
    global CheckForDanglingClasses
    global WorstDanglingCount
    sys._clear_type_cache()
    if doassert is None:
        doassert = AssertOnDanglingClasses
    CMAinit.uninit()
    gc.collect()    # For good measure...
    count =  proj_class_live_object_count()
    #print >>sys.stderr, "CHECKING FOR DANGLING CLASSES (%d)..." % count
    # Avoid cluttering the output up with redundant messages...
    if count > WorstDanglingCount and CheckForDanglingClasses:
        WorstDanglingCount = count
        if doassert:
            print >> sys.stderr, 'STARTING OBJECT DUMP'
            dump_c_objects()
            print >> sys.stderr, 'OBJECT DUMP COMPLETE'
            print 'stdout OBJECT DUMP COMPLETE'
            raise AssertionError("Dangling C-class objects - %d still around" % count)
        else:
            print >> sys.stderr,  ("*****ERROR: Dangling C-class objects - %d still around" % count)