#NEWLINE# def testExceptionsInIdleCallbacks( self ) : #NEWLINE# #INDENT# self . __idle1Calls = 0 #NEWLINE# self . __idle2Calls = 0 #NEWLINE# def idle1( ) : #NEWLINE# #INDENT# self . __idle1Calls += 1 #NEWLINE# raise RuntimeError ( 'I am a very naughty boy' ) #NEWLINE# #UNINDENT# def idle2( ) : #NEWLINE# #INDENT# self . __idle2Calls += 1 #NEWLINE# return True #NEWLINE# #UNINDENT# def stop( ) : #NEWLINE# #INDENT# if ( self . __idle2Calls == 4 ) : #NEWLINE# #INDENT# GafferUI . EventLoop . mainEventLoop ( ) . stop ( ) #NEWLINE# return False #NEWLINE# #UNINDENT# return True #NEWLINE# #UNINDENT# GafferUI . EventLoop . addIdleCallback ( idle1 ) #NEWLINE# GafferUI . EventLoop . addIdleCallback ( idle2 ) #NEWLINE# GafferUI . EventLoop . addIdleCallback ( stop ) #NEWLINE# mh = IECore . CapturingMessageHandler ( ) #NEWLINE# with mh : #NEWLINE# #INDENT# GafferUI . EventLoop . mainEventLoop ( ) . start ( ) #NEWLINE# #UNINDENT# self . assertEqual ( self . __idle1Calls , 1 ) #NEWLINE# self . failUnless ( ( self . __idle2Calls >= 4 ) ) #NEWLINE# self . assertEqual ( len ( mh . messages ) , 1 ) #NEWLINE# self . assertEqual ( mh . messages [ 0 ] . level , IECore . Msg . Level . Error ) #NEWLINE# self . failUnless ( ( 'I am a very naughty boy' in mh . messages [ 0 ] . message ) )