Returning values from custom library

Hi all! I started to use Robot one week ago and I am trying to store a value in the test cases file which is generated in a library written in Python but I am not able to do it.
The library has a class with the same name of the library. I want to store the value in ${x} variable. My code is the following:

*** Test Cases ***
Sum something
${x}= Make a sum
Log ${x}
*** Keywords ***
Make a sum
[Documentation] This performs a sum
calculator.mysum ${number}

calculator.mysum is the function from the library and just prints the number which has β€œ2” by default. The ${x} variable gives me β€˜None’ when the code is executed and I expect β€˜2’.

Thanks in advance!

The printing goes to the log files (or screen).

In you keyword you should assign the result of the library keyword and then return:

*** Test Cases ***
Sum something
    ${x}=    Make a sum
    Log    ${x}

*** Keywords ***
Make a sum
    [Documentation]    This performs a sum
    [Arguments]            ${number}=${None}
    ${value}=    calculator.mysum    ${number}
    RETURN    ${value}
2 Likes