#NEWLINE# @ defer . inlineCallbacks #NEWLINE# def test_binding_before_connecting( self ) : #NEWLINE# #INDENT# queues = dict ( binder = dict ( type = 'PUSH' , binds = [ 'inproc://socketname' ] ) , connecter = dict ( type = 'PULL' , connects = [ 'inproc://socketname' ] ) ) #NEWLINE# self . runtime_environment . configuration_manager . set ( 'zmq.queues' , queues ) #NEWLINE# socket_provider = providers . ZMQSocketProvider ( ) #NEWLINE# context = self . mocker . mock ( ) #NEWLINE# socket_provider . context_factory = ( lambda : context ) #NEWLINE# binder_socket = self . mocker . mock ( ) #NEWLINE# connecter_socket = self . mocker . mock ( ) #NEWLINE# context . socket ( zmq . PUSH ) #NEWLINE# self . mocker . result ( binder_socket ) #NEWLINE# context . socket ( zmq . PULL ) #NEWLINE# self . mocker . result ( connecter_socket ) #NEWLINE# with self . mocker . order ( ) : #NEWLINE# #INDENT# binder_socket . bind ( 'inproc://socketname' ) #NEWLINE# connecter_socket . connect ( 'inproc://socketname' ) #NEWLINE# #UNINDENT# self . mocker . replay ( ) #NEWLINE# socket_provider . configure ( self . runtime_environment ) #NEWLINE# connecter_dependency = dependencies . ResourceDependency ( provider = 'zmq.socket.connecter' ) #NEWLINE# binder_dependency = dependencies . ResourceDependency ( provider = 'zmq.socket.binder' ) #NEWLINE# socket_by_name = dict ( ) #NEWLINE# connecter_dependency . on_resource_ready += ( lambda resource : socket_by_name . __setitem__ ( 'connecter' , resource ) ) #NEWLINE# binder_dependency . on_resource_ready += ( lambda resource : socket_by_name . __setitem__ ( 'binder' , resource ) ) #NEWLINE# self . dependency_manager . add_dependency ( binder_socket ) #NEWLINE# self . dependency_manager . add_dependency ( binder_dependency ) #NEWLINE# self . dependency_manager . resolve_initial_states ( ) #NEWLINE# ( yield util . wait ( 0 ) ) #NEWLINE# self . mocker . verify ( ) #NEWLINE# self . assertEquals ( socket_by_name , dict ( binder = binder_socket , connecter = connecter_socket ) )