#NEWLINE# def check_collection( self , values ) : #NEWLINE# #INDENT# cfunc = values . cfunc #NEWLINE# values = list ( values ) #NEWLINE# hashes = [ cfunc ( x ) for x in values ] #NEWLINE# for x in hashes : #NEWLINE# #INDENT# self . assertIsInstance ( x , utils . INT_TYPES ) #NEWLINE# #UNINDENT# def check_distribution( hashes ) : #NEWLINE# #INDENT# distinct = set ( hashes ) #NEWLINE# if ( len ( distinct ) < ( 0.95 * len ( values ) ) ) : #NEWLINE# #INDENT# counter = defaultdict ( list ) #NEWLINE# for ( v , h ) in zip ( values , hashes ) : #NEWLINE# #INDENT# counter [ h ] . append ( v ) #NEWLINE# #UNINDENT# collisions = [ ( h , v ) for ( h , v ) in counter . items ( ) if ( len ( v ) > 1 ) ] #NEWLINE# collisions = '\n' . join ( ( ( '%s: %s' % ( h , v ) ) for ( h , v ) in sorted ( collisions ) ) ) #NEWLINE# self . fail ( ( 'too many hash collisions: \n%s' % collisions ) ) #NEWLINE# #UNINDENT# #UNINDENT# check_distribution ( hashes )