def test_handle_error_no_handler_and_logger_and_err_msg(self): sock = EventSocket() sock._logger = mock() sock._error_msg = 'isanerror' expect(sock._logger.error).args( 'unhandled error isanerror', exc_info=True ) sock._handle_error( 'exception' )
def test_handle_error_with_handler_and_err_msg(self): sock = EventSocket() sock._parent_error_cb = mock() sock._error_msg = 'isanerror' expect(sock._parent_error_cb).args( sock, 'isanerror', 'exception' ) sock._handle_error( 'exception' )
def test_protected_cb_when_an_error(self): sock = EventSocket() #mock( sock, '_handle_error' ) cb = mock() sock._error_msg = 'it broked' exc = RuntimeError('fale') expect( cb ).args( 'arg1', 'arg2', arg3='foo' ).raises( exc ) expect( sock._handle_error ).args( exc ) assert_equals( None, sock._protected_cb( cb, 'arg1', 'arg2', arg3='foo' ) ) assert_equals( None, sock._error_msg )