Here is the def of the function I’m testing:
def runCMD(cmd,subString=-1,stripSlashes=True,getReturnCode=False):
Here is my test class
import unittest
from class_backups import *
class tests_backups(unittest.TestCase):
def test_runCMD(self):
cLInstance = class_backups()
assert(cLInstance.runCMD("ls",-1,True,True)==0)
# When this module is executed from the command-line, run all its tests
unittest.main()
Here is my error:
E
======================================================================
ERROR: test_runCMD (__main__.tests_backups)
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests_backups.py", line 11, in test_runCMD
assert(cLInstance.runCMD("ls",-1,True,True)==0)
TypeError: runCMD() takes at most 4 arguments (5 given)
----------------------------------------------------------------------
Ran 1 tests in 0.000s
FAILED (errors=1)
What am I doing wrong? Is there an implicit 5th argument? is it self?
I would say that the
runCMDmethod is missingselfas the first argument.Since it’s a bound instance method, Python is sending the instance as the first argument implicitly and that’s why your seeing 5 arguments being passed.