#NEWLINE# def test_multiple_subscribers( self ) : #NEWLINE# #INDENT# topic = '/test_subscribe_receive_json' #NEWLINE# msg_type = 'std_msgs/String' #NEWLINE# client1 = 'client_test_subscribe_receive_json_1' #NEWLINE# client2 = 'client_test_subscribe_receive_json_2' #NEWLINE# msg = String ( ) #NEWLINE# msg . data = 'dsajfadsufasdjf' #NEWLINE# pub = rospy . Publisher ( topic , String ) #NEWLINE# multi = MultiSubscriber ( topic , msg_type ) #NEWLINE# received = { #NEWLINE# #INDENT# 'msg1' : None , #NEWLINE# 'msg2' : None , #NEWLINE# #UNINDENT# } #NEWLINE# def cb1( msg ) : #NEWLINE# #INDENT# received [ 'msg1' ] = msg #NEWLINE# #UNINDENT# def cb2( msg ) : #NEWLINE# #INDENT# received [ 'msg2' ] = msg #NEWLINE# #UNINDENT# multi . subscribe ( client1 , client1 ) #NEWLINE# multi . subscribe ( client2 , cb2 ) #NEWLINE# sleep ( 0.5 ) #NEWLINE# pub . publish ( msg ) #NEWLINE# sleep ( 0.5 ) #NEWLINE# self . assertEqual ( msg . data , received [ 'msg1' ] [ 'data' ] ) #NEWLINE# self . assertEqual ( msg . data , received [ 'msg2' ] [ 'data' ] )