与RobotFramework一起使用的Python返回错误,否则将数字与9和大数字进行比较

Ane*_*med 1 python automated-tests robotframework

这是我的python 2.7代码

def BigNumber(x, y):
    return x if x > y else y
Run Code Online (Sandbox Code Playgroud)

这是我的机器人框架测试用例

Big_Number_tc
    [Tags]    Test_TC
    ${number_big}=    BigNumber    91    10000
    log    ${number_big}
Run Code Online (Sandbox Code Playgroud)

当我运行代码时,显示的输出总是91,而不是10000

如果我独立运行python代码,则显示正确

但是当我使用Robot框架来运行它时,显示错误.

它只发生在其中有9个的数字

我已经尝试过通常的python if else语法,但结果对于9的数字总是错误的

有什么理由和解决方法吗?

JaP*_*PyR 6

默认情况下,Robot Framework将所有标量变量视为字符串,因此您的自定义关键字将字符串"91"与字符串进行比较"10000".有两种选择:

  1. 在关键字内部将参数转换为所需的数据类型
  2. 明确地将数字传递给您的关键字.为此,请使用${}语法即${91}