A script to run all of my project's pyunit tests

travislspencer at gmail.com travislspencer at gmail.com
Fri Aug 19 16:07:25 EDT 2005


travislspencer at gmail.com wrote:
> for file in glob(projHome + "/tests/*.py"):
>     start = file.rfind("/") + 1
>     end = file.rfind(".")
>     moduleName = file[start:end]
>     module = __import__(moduleName)

      klass = module.__dict__[module.__name__]
      tests.append(unittest.makeSuite(klass, "test"))

> allTests = unittest.TestSuite(tests)
> runner = unittest.TextTestRunner(verbosity=2)
>
> runner.run(allTests)

This is still a kludge, but a different and less annoying one.  It
works as long as the TestCase class and module have the same name.

Back to the drawing board...

--
 
Regards,

Travis Spencer




More information about the Python-list mailing list