开发者社区> 问答> 正文

使用Robot Framework从Python中的方法返回值

所以可以说我在python中有这个方法

def get_data(notificaition):
    print("Notification Recived: ", notificaition)

然后我有另一种方法来接收一个事件并获取该事件的值。

def verify_singal_r():
    with Session() as session:
        connection = Connection("http://example/signalr", session)
        print(connection)
        logging.info("got the connection")
        presenceservice = connection.register_hub('MyHub')
        connection.start()
        def print_error(error):
            print('error: ', error)


        connection.error += print_error

        # TODO: NEED TO ADD POST REQUEST HERE
        presenceservice.client.on('Notified', get_data)
        connection.wait(10)

关键字Verify_Signal运行后,我会得到所需的值,然后将它们打印到控制台上

如何使用get_datain robot框架的值?

我试图简单地使用

*** Test Cases ***

Get Event Back
     verify_singal_r
     get_data

但这不起作用,因为get_data需要一个参数。

展开
收起
祖安文状元 2020-02-23 16:28:56 1460 0
1 条回答
写回答
取消 提交回答
  • 你的方法

    def get_data(notificaition):
        print("Notification Recived: ", notificaition)
    
    

    不返回任何内容,因此robot框架关键字也不会返回任何内容。

    2020-02-23 16:29:07
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载