#NEWLINE# def addSuccess( self , test ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# ( rc_deltas , alloc_deltas ) = self . _huntLeaks ( test ) #NEWLINE# #UNINDENT# except AssertionError : #NEWLINE# #INDENT# assert ( not self . wasSuccessful ( ) ) #NEWLINE# return #NEWLINE# #UNINDENT# def check_rc_deltas( deltas ) : #NEWLINE# #INDENT# return any ( deltas ) #NEWLINE# #UNINDENT# def check_alloc_deltas( deltas ) : #NEWLINE# #INDENT# if ( ( 3 * deltas . count ( 0 ) ) < len ( deltas ) ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# if ( not ( set ( deltas ) <= set ( ( 1 , 0 , ( - 1 ) ) ) ) ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# return False #NEWLINE# #UNINDENT# failed = False #NEWLINE# for ( deltas , item_name , checker ) in [ ( rc_deltas , 'references' , check_rc_deltas ) , ( alloc_deltas , 'memory blocks' , check_alloc_deltas ) ] : #NEWLINE# #INDENT# if checker ( deltas ) : #NEWLINE# #INDENT# msg = ( '%s leaked %s %s, sum=%s' % ( test , deltas , self , sum ( deltas ) ) ) #NEWLINE# failed = True #NEWLINE# try : #NEWLINE# #INDENT# raise ReferenceLeakError ( msg ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# exc_info = sys . exc_info ( ) #NEWLINE# #UNINDENT# if self . showAll : #NEWLINE# #INDENT# self . stream . write ( ( '%s = %r ' % ( item_name , deltas ) ) ) #NEWLINE# #UNINDENT# self . addFailure ( test , exc_info ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not failed ) : #NEWLINE# #INDENT# super ( RefleakTestResult , self ) . addSuccess ( test )