rvalid_value support for python-like list literals
The caller of this function may code this single line:
Rvalid Value var1 valid_values=["one", "two"]
Instead of these 2 lines:
${valid_values}= Create List one two
Rvalid Value var1 valid_values=${valid_values}
Change-Id: Ic893c15661e167e2a4711cf10509548ddbc595c8
Signed-off-by: Michael Walsh <micwalsh@us.ibm.com>
diff --git a/lib/gen_robot_valid.py b/lib/gen_robot_valid.py
index 8f761f9..876edcb 100755
--- a/lib/gen_robot_valid.py
+++ b/lib/gen_robot_valid.py
@@ -31,6 +31,13 @@
be equal to one of these values to be
considered valid.
+ If either the invalid_values or the valid_values parms are not of type
+ "list", they will be processed as python code in order to generate a list.
+ This allows the robot programmer to essentially specify a list literal.
+ For example, the robot code could contain the following:
+
+ Rvalid Value var1 valid_values=['one', 'two']
+
Examples of robot calls and corresponding output:
Robot code...
@@ -72,6 +79,13 @@
# Note: get_variable_value() seems to have no trouble with local variables.
var_value = BuiltIn().get_variable_value("${" + var_name + "}")
+ if type(valid_values) is not list:
+ # Evaluate python syntax to convert to a list.
+ exec("valid_values = " + valid_values)
+ if type(invalid_values) is not list:
+ # Evaluate python syntax to convert to a list.
+ exec("invalid_values = " + invalid_values)
+
if var_value is None:
var_value = ""
error_message = "Variable \"" + var_name +\