def resolve_arguments(self, args_and_kwargs, variables=None): """More Pythonic argument handling for interactive :class:`robottools.testrobot.keyword.Keyword` calls. Original ``resolve_arguments`` methods from ``robot.running.handlers`` expect as first argument a single list of Keyword arguments coming from an RFW script:: ['arg0', 'arg1', ..., 'name=value', ...] So there is no chance to pass unstringified named argument values. Only unstringified positional arguments are possible. This wrapper method takes a normal Python `args_and_kwargs` pair instead as first argument:: (arg0, arg1, ...), {name: value, ...} It resolves the named arguments stringified via the original method but returns the original Python values:: [arg0, arg1, ...], [(name, value), ...] Only strings are untouched. So RFW ``'...${variable}...'`` substitution still works. """ posargs, kwargs = args_and_kwargs rfwargs = list(posargs) # prepare 'key=value' strings for original RFW method for name, value in dictitems(kwargs): if not isstring(value): value = repr(value) rfwargs.append(u'%s=%s' % (name, value)) posargs, rfwkwargs = self._resolve_arguments(rfwargs, variables) # and replace values with original non-string objects after resolving kwargslist = [] if isdict(rfwkwargs): # ==> RFW < 3.0 rfwkwargs = dictitems(rfwkwargs) for name, rfwvalue in rfwkwargs: value = kwargs[name] if isstring(value): value = rfwvalue kwargslist.append((name, value)) if hasattr(self, 'run'): # ==> RFW < 3.0 return posargs, dict(kwargslist) # RFW >= 3.0 return posargs, kwargslist
def __dir__(self): """List all Robot Variables (UPPER_CASE), Test Libraries and Keyword (CamelCase) names, which are valid Python identifiers. """ names = super(TestRobot, self).__dir__() variables = self._variables if not isdict(variables): # Robot > 2.8 variables = variables.as_dict() for name in variables: name = name[2:-1] # Strip ${} if isidentifier(name): names.append(name.upper()) for alias, lib in self._libraries.items(): names.append(alias) # dir() returns the Library's CamelCase Keyword names: lib = self[alias] names.extend(dir(lib)) return names
def update(self, mapping=(), **items): if isdict(mapping): mapping = mapping.items() for key, value in chain(mapping, items.items()): self[key] = value