<s> def assert_same_type ( expected , actual ) : <EOL> assert isinstance ( actual , type ( expected ) ) , "<STR_LIT>" % ( type ( expected ) , type ( actual ) ) <EOL> def assert_equal_sequence ( expected , actual ) : <EOL> assert len ( expected ) == len ( actual ) , "<STR_LIT>" % ( <EOL> len ( expected ) , len ( actual ) , actual <EOL> ) <EOL> for i in range ( len ( expected ) ) : <EOL> try : <EOL> assert_equal ( expected [ i ] , actual [ i ] ) <EOL> except AssertionError , assertion_error : <EOL> raise AssertionError ( <EOL> str ( assertion_error ) <EOL> ) <EOL> def assert_equal_set ( expected , actual ) : <EOL> missing = expected . difference ( actual ) <EOL> assert not missing , "<STR_LIT>" % "<STR_LIT:U+002CU+0020>" . join ( missing ) <EOL> extra = actual . difference ( expected ) <EOL> assert not extra , "<STR_LIT>" % "<STR_LIT:U+002CU+0020>" . join ( extra ) <EOL> def assert_equal_dict ( expected , actual ) : <EOL> assert_equal_set ( <EOL> expected = set ( expected . keys ( ) ) , <EOL> actual = set ( actual . keys ( ) ) <EOL> ) <EOL> for key in expected . iterkeys ( ) : <EOL> try : <EOL> assert_equal ( expected [ key ] , actual [ key ] ) <EOL> except AssertionError , assertion_error : <EOL> raise AssertionError ( <EOL> "<STR_LIT>" % ( <EOL> key , <EOL> str ( assertion_error ) , <EOL> ) <EOL> ) <EOL> def assert_equal_value ( expected , actual ) : <EOL> assert expected == actual , "<STR_LIT>" % ( expected , actual ) <EOL> _compare_procs = { <EOL> list : assert_equal_sequence , <EOL> int : assert_equal_value , <EOL> float : assert_equal_value , <EOL> str : assert_equal_value , <EOL> unicode : assert_equal_value , <EOL> dict : assert_equal_dict , <EOL> set : assert_equal_set , <EOL> } <EOL> def assert_equal ( expected , actual ) : <EOL> assert_same_type ( expected , actual ) <EOL> compare_proc = _compare_procs . get ( type ( expected ) , assert_equal_value ) <EOL> compare_proc ( <EOL> expected , <EOL> actual <EOL> ) </s>
