除法似乎在Robotframework中不起作用,我在做什么错?

时间:2019-05-27 16:03:11

标签: python robotframework

我正在尝试使用/运算符进行除法。
最终的浮点数超出了标准。我想念什么?

这是RF的输出:

KEYWORD: BuiltIn.Log ${nearTermsAmount}
Documentation:         

Logs the given message with the given level.
Start / End / Elapsed: 20190527 17:13:09.091 / 20190527 17:13:09.107 / 
17:13:09.107   INFO   3,666.00         
00:00:00.000 KEYWORD: BuiltIn.Log ${nearAllIn}
Documentation:         
 Logs the given message with the given level.
Start / End / Elapsed: 20190527 17:13:09.107 / 20190527 17:13:09.107 
17:13:09.107   INFO   1.607976        
00:00:00.015 KEYWORD: ${calNearTerms/BaseAmount} = BuiltIn.Run Keyword If      ${isBase}, Calculate Terms Amount, ${nearBaseAmount}, ${nearAllIn}, ELSE, Calculate Base Amount, ${nearTermsAmount}, ${nearAllIn}
Documentation:         

Runs the given keyword with the given arguments, if `condition` is true.
Start / End / Elapsed: 20190527 17:13:09.107 / 20190527 17:13:09.122 /   00:00:00.015
00:00:00.015 KEYWORD: rateTicketKeywords.Calculate Base Amount  ${nearTermsAmount}, ${nearAllIn}
Documentation:         

Calculates the base amount out of the given rate
Start / End / Elapsed: 20190527 17:13:09.107 / 20190527 17:13:09.122 / 00:00:00.015 
00:00:00.000 KEYWORD: ${baseAmount} = BuiltIn.Evaluate ${givenAmount} / ${givenRate}
00:00:00.015 KEYWORD: ${result} = rateTicketKeywords.Strip Numeric Commas ${baseAmount}
00:00:00.000 KEYWORD: ${result} = BuiltIn.Convert To Number ${result}, 5
17:13:09.122   INFO   ${calNearTerms/BaseAmount} = 3414.18529          
00:00:00.016 KEYWORD: ${otherAmount} = BuiltIn.Run Keyword If ${isBase}, Strip Numeric Commas, ${nearTermsAmount}, ELSE, Strip Numeric Commas, ${nearBaseAmount}
Documentation:         

Runs the given keyword with the given arguments, if `condition` is true.
Start / End / Elapsed: 20190527 17:13:09.122 / 20190527 17:13:09.138 / 00:00:00.016
00:00:00.016 KEYWORD: rateTicketKeywords.Strip Numeric Commas ${nearBaseAmount}
17:13:09.138   INFO   ${otherAmount} = 2279.88    
00:00:00.000 KEYWORD: ${diff} = BuiltIn.Evaluate ${calNearTerms/BaseAmount} - ${otherAmount}
00:00:00.000 KEYWORD: ${diff} = BuiltIn.Evaluate abs(${diff})
Documentation:         

Evaluates the given expression in Python and returns the results.
Start / End / Elapsed: 20190527 17:13:09.138 / 20190527 17:13:09.138 / 00:00:00.000
17:13:09.138   INFO   ${diff} = 1134.30529  
00:00:00.000 KEYWORD: ${diff} = BuiltIn.Evaluate ${diff} / ${otherAmount}
Documentation:         

Evaluates the given expression in Python and returns the results.
Start / End / Elapsed: 20190527 17:13:09.138 / 20190527 17:13:09.138 / 00:00:00.000
17:13:09.138   INFO   ${diff} = 0.497528505886      
00:00:00.000 KEYWORD: ${status} = BuiltIn.Evaluate ${diff} > 0.0006
00:00:00.015 KEYWORD: BuiltIn.Run Keyword If ${status}, FAIL, the   calculated near terms amount which was inserted in the trade ticked differ to  the near terms amount from the execution dialog, True
Documentation:         

Runs the given keyword with the given arguments, if `condition` is true.
Start / End / Elapsed: 20190527 17:13:09.138 / 20190527 17:13:09.153 / 00:00:00.015
00:00:00.015 KEYWORD: BuiltIn.Fail the calculated near terms amount which was inserted in the trade ticked differ to the near terms amount from the  execution dialog, True
Documentation:         

Fails the test with the given message and optionally alters its tags.



Source code:
Calculate Terms Amount
[Documentation]  Calculates the terms amount out of the given rate
[Arguments]  ${givenAmount}  ${givenRate}
log  ${givenAmount}
${givenAmount}=  Strip Numeric Commas  ${givenAmount}
#log  ${givenAmount}
${termsAmount}=  Evaluate  ${givenAmount} * ${givenRate}
${result}=  Strip Numeric Commas  ${termsAmount}
${result}=  Convert To Number  ${result}  5
[Return]  ${result}

代码测试被测系统完成的数学运算。从应用程序中提取的数字是正确的,我的答案还很遥远。

1 个答案:

答案 0 :(得分:-1)

当我剪切并粘贴“计算基本金额”关键字时,我发现缺少'='符号(请参见下文)。我不确定这样做会做什么,但是要么语法上正确,要么语法检查程序可以使用一些工作:)。

此行:   $ {baseAmount}评估$ {givenAmount} / $ {givenRate} 应该:   $ {baseAmount} =评估$ {givenAmount} / $ {givenRate}