<s> import warnings <EOL> warnings . filterwarnings ( "<STR_LIT:ignore>" , "<STR_LIT>" , <EOL> DeprecationWarning ) <EOL> import unittest <EOL> from md5 import md5 <EOL> from test import test_support <EOL> def hexstr ( s ) : <EOL> import string <EOL> h = string . hexdigits <EOL> r = '<STR_LIT>' <EOL> for c in s : <EOL> i = ord ( c ) <EOL> r = r + h [ ( i >> <NUM_LIT:4> ) & <NUM_LIT> ] + h [ i & <NUM_LIT> ] <EOL> return r <EOL> class MD5_Test ( unittest . TestCase ) : <EOL> def md5test ( self , s , expected ) : <EOL> self . assertEqual ( hexstr ( md5 ( s ) . digest ( ) ) , expected ) <EOL> self . assertEqual ( md5 ( s ) . hexdigest ( ) , expected ) <EOL> def test_basics ( self ) : <EOL> eq = self . md5test <EOL> eq ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> eq ( '<STR_LIT:a>' , '<STR_LIT>' ) <EOL> eq ( '<STR_LIT:abc>' , '<STR_LIT>' ) <EOL> eq ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> eq ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> eq ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> eq ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> def test_hexdigest ( self ) : <EOL> m = md5 ( '<STR_LIT>' ) <EOL> h = m . hexdigest ( ) <EOL> self . assertEqual ( hexstr ( m . digest ( ) ) , h ) <EOL> def test_large_update ( self ) : <EOL> aas = '<STR_LIT:a>' * <NUM_LIT:64> <EOL> bees = '<STR_LIT:b>' * <NUM_LIT:64> <EOL> cees = '<STR_LIT:c>' * <NUM_LIT:64> <EOL> m1 = md5 ( ) <EOL> m1 . update ( aas ) <EOL> m1 . update ( bees ) <EOL> m1 . update ( cees ) <EOL> m2 = md5 ( ) <EOL> m2 . update ( aas + bees + cees ) <EOL> self . assertEqual ( m1 . digest ( ) , m2 . digest ( ) ) <EOL> def test_main ( ) : <EOL> test_support . run_unittest ( MD5_Test ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> test_main ( ) </s>
