-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass embedded args as objects to Run Keyword and its variants.
Earlier variables were replaced in keyword names before keywords were called. This meant that keywords using embedded arguments only go string representations of objects, not objects themselves. The biggest change that the `name` argument passed to `BuiltIn.run_keyword` isn't anymore resolved before calling the keyword. Instead the keyword resolves it itself after first checking does it match some keyword accepting embedded arguments. If it does, `name` is not resolved and variables will be handled later by appropriate runners. The above change ought to be backwards compatible when using `Run Keyword` in data, but if `BuiltIn.run_keyword` is used by a library keyword handling of the `name` argument changes. This only affects situations where the name contains variables or escapes so it shouldn't cause problems in normal usage. Not resolving `name` caused various bigger and smaller changes elsewhere. For example, how run keyword variants were handled in dry run was affected and that logic needed to be changed. The bad and deprecated RUN_KW_REGISTER was enhanced to help with that and its documentation was enhanced at the same time. Fixes #1595.
- Loading branch information
1 parent
f75c5b2
commit 8301773
Showing
17 changed files
with
429 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
atest/testdata/standard_libraries/builtin/embedded_args.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from robot.api.deco import keyword | ||
|
||
|
||
@keyword('Embedded "${argument}" in library') | ||
def embedded(arg): | ||
print(arg) | ||
|
||
|
||
@keyword('Embedded object "${obj}" in library') | ||
def embedded_object(obj): | ||
print(obj) | ||
if obj.name != 'Robot': | ||
raise AssertionError(f"'{obj.name}' != 'Robot'") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.