Possible Duplicate:
Python unittest – invoke unittest.main() with a custom TestSuite
I have a testsuite created with e.g.
suite = unittest.TestSuite()
suite.addTest(module1.MyTest("test_simple"))
suite.addTest(module2.MyTest("test_simple"))
and need to start these tests with unitest.main(). When trying just unitest.main(suite) no tests are run at all. How can I do this with unittest.main() without calling test.TextTestRunner or similar?
You can’t pass a
TestSuiteto main, check out the constructor ofunittest.main.TestProgram(which is wasunittest.mainactually is) and how this class works. The first argument if anything is the module name, not a testsuite.main()actually takes its arguments fromsys.argv, as it is actually intended to be used from the command line and not from within a program. It’s just common to do so for convenience.