Status: Accepted
Owner: ----
Labels: Type-Enhancement Priority-High Target-2.8 bwic

New issue 1383 by pekka.klarck: Support for Python's keyword argument syntax
http://code.google.com/p/robotframework/issues/detail?id=1383

Python has so called keyword argument syntax which allows defining functions like

    def func(**kwargs):
        pass

and then calling them like

    func(foo=1, bar='two')

In this example the value of `kwargs` inside `func` would be a dictionary {'foo': 1, 'bar': 'two'}.

Supporting this syntax with Python based test libraries would sometimes be handy. For example, this would make it easier to add optional configuration parameters to keywords in the new Process library (issue 485). We would like to create keyword like this

    def run_process(command, *args, **conf):
        # ...

and call it like

    Run Process    ls    -h    cwd=/tmp

The idea would be that `conf` in the above example would contain {'cwd': '/tmp'}.

Most likely this could be implemented so that if a function implementing a keyword has keyword arguments, all arguments at the end of the keyword call in format `name=value` would be put into it.

If there are also default values, populating them has preferences:

    def example(foo='bar', **kwargs):
        pass

    Example    foo=zap    kw=arg    second=kw_arg

In the above example `foo` would get value `zap` and `kwargs` would be {'kw': 'arg', 'second': 'kw_arg'}.


--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--

--- You received this message because you are subscribed to the Google Groups "robotframework-commit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to