Skip to content

Instantly share code, notes, and snippets.

@cgallemore
Created August 11, 2013 13:04
Show Gist options
  • Save cgallemore/6204800 to your computer and use it in GitHub Desktop.
Save cgallemore/6204800 to your computer and use it in GitHub Desktop.
mock raw_input
In [1]: import mock
In [2]: mock_input = mock.MagicMock()
In [3]: with mock.patch('__builtin__.raw_input', mock_input):
...: mock_input.return_value = 'foobar'
...: foo = raw_input()
...:
In [4]: foo
Out[4]: 'foobar'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment