Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RobotFramework Create Dictionary with an integer value instead of string

Create Dictionary   sensor_id=1

when using Python gives me:

{'sensor_id': '1'}

Where really I want:

{'sensor_id': 1}

Is there anyway to prevent the robot framework from adding these quotes to my integer values?

like image 546
davegallant Avatar asked Nov 23 '16 21:11

davegallant


2 Answers

In robot, you can coerce a string to an integer by putting it inside ${}

${foo}=  create dictionary    sensor_id=${1}

With the above, the value in the dictionary will be an integer.

For more information see Number Variables in the robot framework user guide.

like image 189
Bryan Oakley Avatar answered Oct 16 '22 22:10

Bryan Oakley


  • literals evaluate to strings (sensor_id=1)
  • ${}'d literals evaluate to integers (sensor_id=${1}) - this is what you need to answer your question
  • ${VAR} variables default to strings
  • Use ${VAR} = Convert To Integer ${VAR} to rebind a variable's type
like image 2
Blake H Avatar answered Oct 16 '22 21:10

Blake H