[TIP] Mocking sys.exit() and replacing it back?
jorge.vargas at gmail.com
Thu Aug 5 20:34:12 PDT 2010
Doing this seems really simple. All we need is something like
#we setup a fake sys.exit() to allow tests to continue
sys.exit = mock_exit
However I have two questions.
1- do I need a tearDown that will replace sys.exit with the original
2- if so which is the best way to do this? store it in self.orig_exit ?
Or the test collector is smart enough to know it has to wipe out and
reimport everything on each testcase ?
In case someone asks this is with unittest2.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the testing-in-python