ldtri0209 / robotframework

Automatically exported from code.google.com/p/robotframework
Apache License 2.0
0 stars 0 forks source link

Python's keyword argument syntax is supported #1383

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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'}.

Original issue reported on code.google.com by pekka.klarck on 14 Mar 2013 at 10:48

GoogleCodeExporter commented 9 years ago

Original comment by mikko.ko...@gmail.com on 19 Mar 2013 at 12:58

GoogleCodeExporter commented 9 years ago

Original comment by mika.han...@gmail.com on 20 Mar 2013 at 3:27

GoogleCodeExporter commented 9 years ago
Done 
https://code.google.com/p/robotframework/source/detail?r=9ea710550f77d6f544f2687
e0f4edb029f9f1a43

Original comment by mika.han...@gmail.com on 21 Mar 2013 at 1:41

GoogleCodeExporter commented 9 years ago
Other changes in revision 61867ad0783f and revision f8f75df26942.

Original comment by pekka.klarck on 2 Apr 2013 at 11:02

GoogleCodeExporter commented 9 years ago

Original comment by jussi.ao...@gmail.com on 10 May 2013 at 12:24

GoogleCodeExporter commented 9 years ago
Documentation is covered by issue 1430

Original comment by jussi.ao...@gmail.com on 10 May 2013 at 12:26

GoogleCodeExporter commented 9 years ago

Original comment by robotframework@gmail.com on 13 May 2013 at 9:09

GoogleCodeExporter commented 9 years ago

Original comment by anssi.sy...@eficode.com on 31 May 2013 at 12:39

GoogleCodeExporter commented 9 years ago

Original comment by tatu.ka...@eficode.com on 31 May 2013 at 2:03