Hopefully this is an easy question for someone to answer. I have a directory
structure like so:

alltest.py
prog.py
../package
     __init__.py
     mod1.py
     test_mod1.py
     modn. py
     (and so on...)

Each test_mod*.py file contains some PyUnit test cases. I am using the
following code in alltest.py to run all the unit test modules:

mod_to_test = [package.mod1, package.mod2]

def suite():
   # create TestSuite object
   alltests = unittest.TestSuite()
   # load all modules define in the module list
   for module in map(__import__, mod_to_test):
      alltests.addTest(unittest.findTestCases(module))
   return alltest

if __name__ == '__main__':
   unittest.main(defaultTest='suite')

My guess is there is something needed in __init__.py to get this work. Any
advice?
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to