def test_protected_cb_when_no_error(self): sock = EventSocket() cb = mock() expect( cb ).args( 'arg1', 'arg2', arg3='foo' ).returns( 'result' ) assert_equals( 'result', sock._protected_cb( cb, 'arg1', 'arg2', arg3='foo' ) )
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 )