Python 分部不';我似乎无法在机器人框架下工作,我做错了什么?

Python 分部不';我似乎无法在机器人框架下工作,我做错了什么?,python,robotframework,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

我正在尝试使用
/
运算符进行除法。
由此产生的浮点数太离谱了。我错过了什么

这是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}

代码测试被测试系统所做的数学运算。从应用程序中提取的数字是正确的,我的答案是错误的。

当我剪切并粘贴Calculate Base Amount关键字时,我注意到缺少“=”符号(见下文)。我不确定这会做什么,但它在语法上是正确的,或者语法检查器可能需要一些工作:)

这一行:

${baseAmount}  Evaluate  ${givenAmount} / ${givenRate}
应该是:

${baseAmount}=  Evaluate  ${givenAmount} / ${givenRate}

这个日志转储id很难读取和遵循;将来尽量把它限制在手头的问题上。您已经包含了“Calculate Terms Amount”的来源,但在日志中可以看到,从未运行过关键字-执行的是“Calculate Base Amount”;因此,
Run关键字If${isBase}
分支到它。嗨,托多,谢谢你指出这一点。我也包括了基本金额法。要汇总日志,请使用givenAmount=3666.0。给定的速率为1.60796。将第一个除以第二个应返回2279.88。结果是3414.18529。为什么?Calc Base Amount的代码如下:Calculate Base Amount[文档]根据给定的速率计算基本金额[参数]${givenAmount}${givenRate}${BaseMount}Evaluate${givenAmount}/${givenRate}${result}=转换为数字${result}5[返回]${result}
=
是可选的,不提供任何额外的好处。