python - String variable args are treated as dict types in robot framework -


*** test cases *** log test   run keyword logtype  *** keyword *** logtype   ${type_object}= evaluate  type( ${tc_args} )      log console  type object ${type_object} 

when run command, pybot -v tc_args:'{"a":"b"}' a.robot , robot prints,

the type object <type 'dict'> 

but, isn't default behavior treat single quoted literals strings? so, ideally must have printed <type 'str'> instead of <type 'dict'>.

your variable string. check it, try dictionary keyword on (like "get dictionary" collections lib) , see fails.

run code see it:

*** settings *** library  collections  *** test cases *** log test   # let's test proper dictionary    ${dict} =  create dictionary   b   ${value} =  dictionary  ${dict}    should equal  ${value}  b   log console  ${\n}this real dictionary   # ${tc_args} passed on command line   # evaluate might let thing have dict   ${type_object} =  evaluate  type( ${tc_args} )      log console  type object ${type_object}   # in fact string , doing dict operation fail   dictionary  ${type_object}  

to understand why dict type evaluate, have understand evaluate "evaluating given expression in python , returns results.". take argument plain string launch python on python command line.

now if check argument on python command line, here get:

$ python python 2.7.9 (default, dec 19 2014, 06:00:59) [gcc 4.2.1 compatible apple llvm 6.0 (clang-600.0.56)] on darwin type "help", "copyright", "credits" or "license" more information. >>> type({"a":"b"}) <type 'dict'> 

which totally normal, because "string" {"a":"b"} how declare dictionary in python.

so:


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -