#NEWLINE# def test_handled( self ) : #NEWLINE# #INDENT# o = OpenerDirector ( ) #NEWLINE# meth_spec = [ [ 'http_open' , 'ftp_open' , 'http_error_302' ] , [ 'ftp_open' ] , [ ( 'http_open' , 'return self' ) ] , [ ( 'http_open' , 'return self' ) ] ] #NEWLINE# handlers = add_ordered_mock_handlers ( o , meth_spec ) #NEWLINE# req = Request ( 'http://example.com/' ) #NEWLINE# r = o . open ( req ) #NEWLINE# self . assertEqual ( r , handlers [ 2 ] ) #NEWLINE# calls = [ ( handlers [ 0 ] , 'http_open' ) , ( handlers [ 2 ] , 'http_open' ) ] #NEWLINE# for ( expected , got ) in zip ( calls , o . calls ) : #NEWLINE# #INDENT# ( handler , name , args , kwds ) = got #NEWLINE# self . assertEqual ( ( handler , name ) , expected ) #NEWLINE# self . assertEqual ( args , ( req , ) )