Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. >>> import mock
  2. >>> m = mock.Mock()
  3. >>> m.assert_called_once() # Old version of Mock? This may not be what you expect.
  4. <Mock name='mock.assert_called_once()' id='4558624144'>
  5.  
  6. >>> assert_called_once = mock.Mock.assert_called_once # Doesn't exist. Now you know!
  7. Traceback (most recent call last):
  8. File "<stdin>", line 1, in <module>
  9. AttributeError: type object 'Mock' has no attribute 'assert_called_once'
  10.  
  11. >>> assert_called_once_with = mock.Mock.assert_called_once_with # There it is.
  12.  
  13. >>> assert_called_once_with(m) # This does the right thing.
  14. Traceback (most recent call last):
  15. File "<stdin>", line 1, in <module>
  16. File ".../mock.py", line 845, in assert_called_once_with
  17. raise AssertionError(msg)
  18. AssertionError: Expected to be called once. Called 0 times.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement