Отделение не работает в Robotframework, что я делаю не так? - PullRequest
0 голосов
/ 27 мая 2019

Я пытаюсь выполнить деление с помощью оператора /.
Полученное число с плавающей запятой находится далеко от цели.Что я пропустил?

Это вывод из 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 голосов
/ 28 мая 2019

Когда я вырезал и вставил ключевое слово «Рассчитать базовую сумму», я заметил, что отсутствует символ «=» (см. Ниже). Я не уверен, что это будет делать, но либо это синтаксически правильно, либо проверка синтаксиса может использовать некоторую работу :).

Эта строка: $ {baseAmount} Evaluate $ {GivenAmount} / $ {GivenRate} Должно быть: $ {baseAmount} = Оценить $ {GivenAmount} / $ {GivenRate}

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...