#NEWLINE# def test_exit( self ) : #NEWLINE# #INDENT# b = wspbus . Bus ( ) #NEWLINE# self . log ( b ) #NEWLINE# self . responses = [ ] #NEWLINE# num = 3 #NEWLINE# for index in range ( num ) : #NEWLINE# #INDENT# b . subscribe ( 'stop' , self . get_listener ( 'stop' , index ) ) #NEWLINE# b . subscribe ( 'exit' , self . get_listener ( 'exit' , index ) ) #NEWLINE# #UNINDENT# b . exit ( ) #NEWLINE# self . assertEqual ( set ( self . responses ) , set ( ( [ ( msg % ( i , 'stop' , None ) ) for i in range ( num ) ] + [ ( msg % ( i , 'exit' , None ) ) for i in range ( num ) ] ) ) ) #NEWLINE# self . assertEqual ( b . state , b . states . EXITING ) #NEWLINE# self . assertLog ( [ 'Bus STOPPING' , 'Bus STOPPED' , 'Bus EXITING' , 'Bus EXITED' ] )