def mock_protocol(): mproto = Mock(RPCProtocol) foo = Mock(RPCResponse) foo.result = None mproto.parse_reply = Mock(return_value=foo) return mproto