commit c7be51d1d49cab86ce72b0d20b5ca682b185afbf
Author: Jan Tluka <jtluka(a)redhat.com>
Date: Wed Jun 25 16:02:31 2014 +0200
TaskAPI: don't use kwargs for passing options to test module
Currently the TaskAPI uses kwargs to pass options to a test module. If a
user decides to run test module from XML there are no limitations on the
name of an option. But when the user uses TaskAPI get_module method the
option names are limited because of Python reserved words [1]. Developer
of a test might want to use e.g. 'if' for a variable containing an interface
to use for testing. To be consistent between the two approaches I'm sending
a patch that uses parameter 'options' of type dictionary for passing the
test module options.
Example:
Old: my_mod = ctl.get_module("Multicast",
setup="send_simple",
duration=10,
condition="status == 'pass'")
New: my_mod = ctl.get_module("Multicast", options={
"setup": "send_simple",
"duration": 10,
"condition": "status ==
'pass'"})
I have tested the patch using Multicast test module and it works fine.
[1]
https://docs.python.org/2/reference/lexical_analysis.html#keywords
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/Task.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/lnst/Controller/Task.py b/lnst/Controller/Task.py
index 59f17c5..315b099 100644
--- a/lnst/Controller/Task.py
+++ b/lnst/Controller/Task.py
@@ -53,7 +53,7 @@ class ControllerAPI(object):
host = self._hosts[host_id]
return HostAPI(self, host_id, host)
- def get_module(self, name, **kwargs):
+ def get_module(self, name, options={}):
"""
Initialize a module to be run on a host.
@@ -63,7 +63,7 @@ class ControllerAPI(object):
:return: The module handle.
:rtype: ModuleAPI
"""
- return ModuleAPI(name, kwargs)
+ return ModuleAPI(name, options)
def wait(self, seconds):
"""