
robotframework - issue #1684
`Run Keyword And Return` does not escape return values correctly
Hello!
Documentation for the keyword 'Run Keyword And Return' claims that following code samples should be equivalent to each other:
Run Keyword And Return My Keyword arg1 arg2
and
${result} = My Keyword arg1 arg2
Return From Keyword ${result}
But it is not true when "My Keyword" returns string that contains some text that may look like Robot Framework variable. In the attached file I demonstrate an example of this. Looks like keyword "Run Keyword And Return" not just simply return given value, but also tries to evaluate it.
What I've got:
$ pybot test.txt
Test
Direct Call With "[Return]" Works Fine | PASS |
Direct Call With "Return From Keyword" Works Fine | PASS |
Old-Fashion Wrapping Works Fine | PASS |
New-Fasion Wrapping Fails | FAIL |
Replacing variables from keyword return value failed: Resolving variable '${client-email}' failed: Non-existing variable '${client}'.
Test | FAIL | 4 critical tests, 3 passed, 1 failed
4 tests total, 3 passed, 1 failed
$ pybot --version Robot Framework 2.8.4 (Python 2.7.5+ on linux2)
- test.txt 913
Comment #1
Posted on Apr 14, 2014 by Happy RhinoInteresting. Need to investigate this a bit more thoroughly to understand why this happens and could we fix it.
Comment #2
Posted on Apr 22, 2014 by Happy RhinoThe problem is that Run Keyword And Return doesn't escape return values it gets before internally using Return From Keyword to actually return the value. The bug doesn't only cause problems with strings that contain variable syntax, like ${client-email}
in the original description, but also any usage of backslashes. Backslashes are unescaped and thus e.g. returned c:\temp
turns into c:<tab>emp
.
Comment #3
Posted on Apr 22, 2014 by Happy RhinoThis issue was updated by revision e086f9837c65.
Fixed Run Keyword And Return and that automatically also fixed Run Keyword And Return If. Also added tests for both.
Comment #4
Posted on Apr 22, 2014 by Helpful CamelGreat! Thank you!
Status: Done
Labels:
Type-Defect
Priority-Medium
Target-2.8.5