Pass exit=False
to the unittest.main()
call (documentation):
unittest.main(exit=False)
Here's what I'm getting on the console:
$ python test.py
This is test001
.This is test002
.
----------------------------------------------------------------------
Ran 2 tests in 0.000s
OK
Done
FYI, under the hood unittest's TestProgram.runTests()
calls sys.exit()
if the value of exit
is True
(which is by default):
def runTests(self):
...
if self.exit:
sys.exit(not self.result.wasSuccessful())