#NEWLINE# def test_addObserverInDispatch( self ) : #NEWLINE# #INDENT# '\n        Test for registration of an observer during dispatch.\n        ' #NEWLINE# d = EventDispatcher ( ) #NEWLINE# msg = Element ( ( 'ns' , 'message' ) ) #NEWLINE# cb = CallbackTracker ( ) #NEWLINE# def onMessage( _ ) : #NEWLINE# #INDENT# d . addObserver ( '/message' , cb . call ) #NEWLINE# #UNINDENT# d . addOnetimeObserver ( '/message' , onMessage ) #NEWLINE# d . dispatch ( msg ) #NEWLINE# self . assertEquals ( cb . called , 0 ) #NEWLINE# d . dispatch ( msg ) #NEWLINE# self . assertEquals ( cb . called , 1 ) #NEWLINE# d . dispatch ( self ) #NEWLINE# self . assertEquals ( cb . called , 2 )