i have following python code (a bit simplified, but it did make the same error).
class traffic(object):
def __init__(self, testObj):
try:
<do something>
except AssertionError:
sys.exit (1)
def add(self, phase='TEST'):
<do something>
def check(self, phase='TEST'):
<do something>
class testcase(object):
def __init__(self):
try:
<do something>
except AssertionError:
sys.exit (1)
def addSeqPost(self, cmdObj):
print "add Seq. for POST"
cmdObj(phase='POST')
tc = testcase()
test = traffic(tc)
tc.addSeqPost(test.add())
I get the below TypeError:
Traceback (most recent call last):
File "test.py", line 25, in <module>
tc.addSeqPost(test.add())
File "test.py", line 20, in addSeqPost
cmdObj(phase='POST')
TypeError: 'NoneType' object is not callable
If i change my code to, it works, but it is not what i would like:
def addSeqPost(self, cmdObj):
print "add Seq. for POST"
cmdObj.add(phase='POST')
tc.addSeqPost(test())
I would like to make it more general because the test() could have more methods that i would like to pass into tc.addSeqPost(), like tc.addSeqPost(test.check()).
Thanks in adv. for your time and help
After the help from alKid.
One issue remains, what if i want to pass a parameter with test.check(duration=5)? As soon i do that i got the same TypeError...But i don't want/need to return anything from add!!!
Example:
...
def check(self, phase='TEST', duration=0):
<do something>
tc = testcase()
test = traffic(tc)
tc.addSeqPost(test.add)
tc.addSeqPost(test.check(duration=5))