Hello,<div><br></div><div>Doing this seems really simple. All we need is something like</div><div><div><br></div><div>def mock_exit(exit_status):</div><div>    return exit_status</div><div><br></div><div>class RunCommand(TestCase):</div>
<div><br></div><div>    def setUp(self):</div><div>        #we setup a fake sys.exit() to allow tests to continue</div><div>        sys.exit = mock_exit</div></div><div><br></div><div>However I have two questions. </div><div>
<br></div><div>1- do I need a tearDown that will replace sys.exit with the original function?</div><div>2- if so which is the best way to do this? store it in self.orig_exit ?</div><div><br></div><div>Or the test collector is smart enough to know it has to wipe out and reimport everything on each testcase ?</div>
<div><br></div><div>In case someone asks this is with unittest2.</div>