I know how to set attribute for a class, but can't find how to set for a file..
flow = ['1','4','5','2']
def test_generator(test):
def test_parser(self):
print test
return test_parser
class API_tests(unittest.TestCase):
pass
for test in flow:
test_name = 'test_%s' % test
test = test_generator(test)
setattr(API_tests, test_name, test)
this, will work.
I want to replace the API_tests on setattr() to be the file as object instead of the class, so that this file will be appended with the functions (test_generator X 4) I set them dynamically
my expected result as I run 'nosetests -v' on command line is it will show '4 tests passed'
this question can be in other works: how to get the current file as an object
Thanks