<s> class ExpectationFailedException ( Exception ) : <EOL> pass <EOL> class ExpectedException ( object ) : <EOL> def __init__ ( self , excs ) : <EOL> if isinstance ( excs , BaseException ) : <EOL> excs = ( excs , ) <EOL> self . excs = excs <EOL> def __enter__ ( self ) : <EOL> pass <EOL> def __exit__ ( self , type , val , tback ) : <EOL> if not val : <EOL> raise ExpectationFailedException ( "<STR_LIT>" ) <EOL> if not isinstance ( val , self . excs ) : <EOL> raise ExpectationFailedException ( "<STR_LIT>" % ( val , self . excs ) ) <EOL> print "<STR_LIT>" , type . __name__ <EOL> return True <EOL> expected_exception = ExpectedException <EOL> d = { } <EOL> print d . get ( <NUM_LIT:1> ) <EOL> print d . setdefault ( <NUM_LIT:2> ) <EOL> print d . pop ( <NUM_LIT:2> ) <EOL> print d . pop ( <NUM_LIT:2> , None ) <EOL> print d . pop ( <NUM_LIT:2> , None ) <EOL> with expected_exception ( KeyError ) : <EOL> print d . pop ( <NUM_LIT:2> ) <EOL> print min ( [ <NUM_LIT:1> ] ) <EOL> print min ( [ <NUM_LIT:1> ] , None ) <EOL> with expected_exception ( AttributeError ) : <EOL> print getattr ( object ( ) , "<STR_LIT>" ) <EOL> print getattr ( object ( ) , "<STR_LIT>" , None ) <EOL> print range ( <NUM_LIT:5> ) <EOL> with expected_exception ( TypeError ) : <EOL> print range ( <NUM_LIT:5> , None ) <EOL> print range ( <NUM_LIT:5> , <NUM_LIT:10> ) <EOL> print list ( xrange ( <NUM_LIT:5> ) ) <EOL> with expected_exception ( TypeError ) : <EOL> print list ( xrange ( <NUM_LIT:5> , None ) ) <EOL> print list ( xrange ( <NUM_LIT:5> , <NUM_LIT:10> ) ) </s>
