It seems that python nosetest will quit when encountered sys.exit()
, and mocking of this builtin doesn't work.
You can try catching the SystemExit exception. It is raised when someone calls sys.exit()
.
with self.assertRaises(SystemExit):
myFunctionThatSometimesCallsSysExit()