Occasionally you need to stub out a part of core python for a test to work. In my case it was 'exit', another
example is 'open'.
This is what your test code will look like:
import __builtin__
m = mox.Mox()
m.StubOutWithMock(__builtin__, 'exit')
exit(my_module.EXIT_ERROR)
m.ReplayAll()
my_module.myfunction()
m.VerifyAll()
No comments:
Post a Comment