#NEWLINE# def test_hash( ) : #NEWLINE# #INDENT# empty_hash = sha1 ( ) . hexdigest ( ) #NEWLINE# with named_temporary_file ( ) as fp : #NEWLINE# #INDENT# fp . flush ( ) #NEWLINE# assert ( string == CacheHelper . hash ( fp . name ) ) #NEWLINE# #UNINDENT# with named_temporary_file ( ) as fp : #NEWLINE# #INDENT# string = ( ( ( b'asdf' * 1024 ) * sha1 ( ) . block_size ) + b'extra padding' ) #NEWLINE# fp . write ( string ) #NEWLINE# fp . flush ( ) #NEWLINE# assert ( sha1 ( string ) . hexdigest ( ) == CacheHelper . hash ( fp . name ) ) #NEWLINE# #UNINDENT# with named_temporary_file ( ) as fp : #NEWLINE# #INDENT# empty_hash = sha1 ( ) #NEWLINE# fp . write ( b'asdf' ) #NEWLINE# fp . flush ( ) #NEWLINE# hash_output = CacheHelper . hash ( fp . name , digest = empty_hash ) #NEWLINE# assert ( hash_output == empty_hash . hexdigest ( ) )