#NEWLINE# def test_observerRaisingException( self ) : #NEWLINE# #INDENT# '\n        Test that exceptions in observers do not bubble up to dispatch.\n\n        The exceptions raised in observers should be logged and other\n        observers should be called as if nothing happened.\n        ' #NEWLINE# class OrderedCallbackList ( utility . CallbackList ) : #NEWLINE# #INDENT# def __init__( self ) : #NEWLINE# #INDENT# self . callbacks = OrderedDict ( ) #NEWLINE# #UNINDENT# #UNINDENT# class TestError ( Exception ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# def raiseError( _ ) : #NEWLINE# #INDENT# raise TestError ( ) #NEWLINE# #UNINDENT# d = EventDispatcher ( ) #NEWLINE# cb = CallbackTracker ( ) #NEWLINE# originalCallbackList = utility . CallbackList #NEWLINE# try : #NEWLINE# #INDENT# utility . CallbackList = OrderedCallbackList #NEWLINE# d . addObserver ( '//event/test' , raiseError ) #NEWLINE# d . addObserver ( '//event/test' , cb . call ) #NEWLINE# try : #NEWLINE# #INDENT# d . dispatch ( None , '//event/test' ) #NEWLINE# #UNINDENT# except TestError : #NEWLINE# #INDENT# self . fail ( 'TestError raised. Should have been logged instead.' ) #NEWLINE# #UNINDENT# self . assertEqual ( 1 , len ( self . flushLoggedErrors ( TestError ) ) ) #NEWLINE# self . assertEqual ( 1 , cb . called ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# utility . CallbackList = originalCallbackList