Skip to content

Instantly share code, notes, and snippets.

@zefciu
Created July 5, 2013 13:23
Show Gist options
  • Save zefciu/5934496 to your computer and use it in GitHub Desktop.
Save zefciu/5934496 to your computer and use it in GitHub Desktop.
A way to test sys.exit with mocks
import sys
import unittest
import mock
@mock.patch('sys.exit')
class Test(unittest.TestCase):
def test_ok(self, exit):
sys.exit(-1)
sys.exit.assert_called_with(-1)
def test_fail(self, exit):
sys.exit(-2)
sys.exit.assert_called_with(-1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment