Advertisement
jimyeh

Create a mock function in python

Jun 14th, 2012
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. >>> from mock import create_autospec
  2. >>> def my_func(a, b, c):
  3. ...     print a, b, c
  4. ...    
  5. >>> my_mock_func = create_autospec(my_func, return_value="I am a mock")
  6. >>> my_mock_func()
  7. Traceback (most recent call last):
  8.   File "<input>", line 1, in <module>
  9.   File "<string>", line 2, in my_func
  10. TypeError: <lambda>() takes exactly 3 arguments (0 given)
  11. >>> my_mock_func(1, 2, 3)
  12. 'I am a mock'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement