I'm making unittests with python. I am not using any automatical test discovery. I am assembling TestCases into a TestSuite manually.
I can run these tests with unittest.TextTestRunner().run(suite), I would like to run them with unittest.main() so that I can use command line options (like -v/--failfast). The documentation says that unittest.main() can take a TestRunner option.
How to convert my TestSuite into a TestRunner?
Near duplicate of How to run a testsuite with unittest.main (answer copy-and-pasted):
You can't pass a TestSuite to main, check out the constructor of unittest.main.TestProgram (which is was unittest.main actually is) and how this class works. The first argument if anything is the module name, not a testsuite.
main() actually takes its arguments from sys.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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With