#NEWLINE# def check_object( self , cls , digest_size , key ) : #NEWLINE# #INDENT# if ( key is not None ) : #NEWLINE# #INDENT# obj1 = cls ( key ) #NEWLINE# obj2 = cls ( key , b'string' ) #NEWLINE# h1 = cls ( key , b'string' ) . digest ( ) #NEWLINE# obj3 = cls ( key ) #NEWLINE# obj3 . update ( b'string' ) #NEWLINE# h2 = obj3 . digest ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# obj1 = cls ( ) #NEWLINE# obj2 = cls ( b'string' ) #NEWLINE# h1 = cls ( b'string' ) . digest ( ) #NEWLINE# obj3 = cls ( ) #NEWLINE# obj3 . update ( b'string' ) #NEWLINE# h2 = obj3 . digest ( ) #NEWLINE# #UNINDENT# self . assertEqual ( h1 , h2 ) #NEWLINE# self . assertTrue ( hasattr ( obj1 , 'digest_size' ) ) #NEWLINE# if ( digest_size is not None ) : #NEWLINE# #INDENT# self . assertEqual ( obj1 . digest_size , digest_size ) #NEWLINE# #UNINDENT# self . assertEqual ( obj1 . digest_size , len ( h1 ) ) #NEWLINE# obj1 . update ( b'string' ) #NEWLINE# obj_copy = obj1 . copy ( ) #NEWLINE# self . assertEqual ( obj1 . digest ( ) , obj_copy . digest ( ) ) #NEWLINE# self . assertEqual ( obj1 . hexdigest ( ) , obj_copy . hexdigest ( ) ) #NEWLINE# ( digest , hexdigest ) = ( obj1 . digest ( ) , obj1 . hexdigest ( ) ) #NEWLINE# hd2 = '' #NEWLINE# for byte in digest : #NEWLINE# #INDENT# hd2 += ( '%02x' % byte ) #NEWLINE# #UNINDENT# self . assertEqual ( hd2 , hexdigest )