I was trying to run all my unit test unit from the unit test object:
def run_unit_test_for_user(f,*args,**kwargs):
test = Test_code(f,args,kwargs)
test.run()
class Test_code(unittest.TestCase):
def __init__(self,f,args,kwargs):
self.f = f, ...etc...
pass
def test1(self):
#do stuff
def test2(self):
#do stuff
def test3(self):
#do stuff
however I get errors like:
Traceback (most recent call last):
File "my_module.py", line 191, in <module>
user_test.run_unit_test_for_user(Test_code)
File "/Users/user/path/my_module.py", line 6, in run_unit_test_for_user
test.run()
File "/Users/user/miniconda3/envs/eit/lib/python3.6/unittest/case.py", line 576, in run
testMethod = getattr(self, self._testMethodName)
AttributeError: 'Test_code' object has no attribute '_testMethodName'
why is it so difficult? I need to feed code/variables etc from another module so I dont want to do:
unittest.main()
because I need to pass arguments from other already running code.
I am not using command line nor do I wish, please don't suggest it.