本文整理汇总了Python中robot.libraries.BuiltIn.BuiltIn.iteritems方法的典型用法代码示例。如果您正苦于以下问题:Python BuiltIn.iteritems方法的具体用法?Python BuiltIn.iteritems怎么用?Python BuiltIn.iteritems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类robot.libraries.BuiltIn.BuiltIn
的用法示例。
在下文中一共展示了BuiltIn.iteritems方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_opts_from_robot
# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import iteritems [as 别名]
def _get_opts_from_robot(self):
"""
Pulls environment from PO_ environment file
"""
ret = {}
robot_vars = BuiltIn().get_variables()
for var, val in robot_vars.iteritems():
ret[self._normalize(var)] = val
return ret
示例2: my_import_resource
# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import iteritems [as 别名]
def my_import_resource(path):
r"""
Import the resource file specified in path.
Description of arguments:
path The path to your resource file.
This function is a wrapper for BuiltIn().import_resource() and provides
the following benefits:
- When you invoke a robot program from a command line, you may specify
program parameters as follows:
-v --variable name:values
For example:
robot -v parm_x:1 file_x.robot
When you do "Resource utils_x.robot" in a .robot program, it processes
"utils_x.robot" BEFORE your command line parms are processed, as one
might expect. On the other hand, if one of your python library files
were to run BuiltIn().import_resource("utils_x.robot"), it will process
"utils_x.robot" AFTER your program parms are processed. Let's suppose
that utils_x.robot contains the following:
*** Variables ***
${parm_x} ${0}
If your program is invoked like this:
robot -v parm_x:3 file_x.robot
And if your program has a python library file that invokes
BuiltIn().import_resource("utils_x.robot"), then parm_x will get set to
${0}. In other words, instead of utils_x.robot serving to set a default
value for parm_x, it actually causes the user's specification of
"-v parm_x:3" to be overwritten.
This function will remedy that problem by keeping your -v parms intact.
- The problems with -v parms mentioned above are also found with variables
from your file_x.robot "** Variables **" section. Namely, they may get
overwritten when import_resource() is used. This function will likewise
remedy that problem.
"""
# Retrieve the values of all current variables into a dictionary.
pre_var_dict = BuiltIn().get_variables()
# Do the import.
BuiltIn().import_resource(path)
# Once again, retrieve the values of all current variables into a
# dictionary.
post_var_dict = BuiltIn().get_variables()
# If any variable values were changed due to the prior import, set them
# back to their original values.
for key, value in post_var_dict.iteritems():
if key in pre_var_dict:
if value != pre_var_dict[key]:
global_var_name = re.sub("[@&]", "$", key)
BuiltIn().set_global_variable(global_var_name,
pre_var_dict[key])
示例3: _get_opts_from_robot
# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import iteritems [as 别名]
def _get_opts_from_robot(self):
ret = {}
robot_vars = BuiltIn().get_variables()
for var, val in robot_vars.iteritems():
ret[self._normalize(var)] = val
return ret