Do you ever wonder why there is an extra "False" printed at the end of each run for unit tests?
C:\Code\sample>ipy UnitTests.py
.....
----------------------------------------------------------------------
Ran 5 tests in 0.395s
OK
FalseIt looks like there is an exit statement buried inside the unit test framework. We can eliminate the problem pretty easily with the addition of a try/except around the unit test execution. Here is the code to put at the end of your unit test script:
if __name__ == '__main__':
try:
unittest.main()
except SystemExit:
pass
This catches and eats the SystemExit exception, and runs without printing the "False" at the end of the execution:
C:\Code\sample>ipy UnitTests.py
.....
----------------------------------------------------------------------
Ran 5 tests in 0.387s
OK
cheers!