python - 使用机器人框架从 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_data
机器人框架的价值?
我试图简单地使用
*** Test Cases ***
Get Event Back
verify_singal_r
get_data
但这不起作用,因为 get_data 需要一个参数。
解决方案
你的功能
def get_data(notificaition):
print("Notification Recived: ", notificaition)
期待一个论点
但是,当您在机器人框架中调用它时
*** Test Cases ***
Get Event Back
verify_singal_r
get_data
你没有提供任何论据。
你可以试试这样的
*** Variables ***
${notification} Test
*** Test Cases ***
Get Event Back
verify_singal_r
get_data ${notification}
这将解决您的问题。
推荐阅读
- javascript - 无法在 React JS 中的 handlechange 中接收数据
- mysql - 找不到在模式内否定正则表达式的方法
- javascript - React Native - 键盘打开/关闭动画后,ScrollView的高度发生变化
- python - 仅将更改应用于未知边界(墙壁)内的表格
- android - 无法从 Firebase 中检索用户数据
- laravel - 如何计算一个类别被选择了多少次
- azure - 使用 Azure AD 对在 VM 上运行的网站进行身份验证
- php - 如何为wordpress创建分页?
- vim - 有没有一种干净的方法来增加 Vim 中的“BufWrite”自动命令?
- sql - 在特定值之后没有行