<s> import sha <EOL> import unittest <EOL> from test import test_support <EOL> class SHATestCase ( unittest . TestCase ) : <EOL> def check ( self , data , digest ) : <EOL> obj = sha . new ( data ) <EOL> computed = obj . hexdigest ( ) <EOL> self . assert_ ( computed == digest ) <EOL> computed_again = obj . hexdigest ( ) <EOL> self . assert_ ( computed == computed_again ) <EOL> digest = obj . digest ( ) <EOL> hexd = "<STR_LIT>" <EOL> for c in digest : <EOL> hexd += '<STR_LIT>' % ord ( c ) <EOL> self . assert_ ( computed == hexd ) <EOL> def test_case_1 ( self ) : <EOL> self . check ( "<STR_LIT:abc>" , <EOL> "<STR_LIT>" ) <EOL> def test_case_2 ( self ) : <EOL> self . check ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> def test_case_3 ( self ) : <EOL> self . check ( "<STR_LIT:a>" * <NUM_LIT> , <EOL> "<STR_LIT>" ) <EOL> def test_case_4 ( self ) : <EOL> self . check ( chr ( <NUM_LIT> ) * <NUM_LIT> , <EOL> '<STR_LIT>' ) <EOL> def test_main ( ) : <EOL> test_support . run_unittest ( SHATestCase ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> test_main ( ) </s>
