Skip to content

Instantly share code, notes, and snippets.

@YoniTsafir
Created July 25, 2011 17:27
Show Gist options
  • Save YoniTsafir/1104645 to your computer and use it in GitHub Desktop.
Save YoniTsafir/1104645 to your computer and use it in GitHub Desktop.
mock 0.8 beta1 bug
# Old version:
>>> from mock import MagicMock
>>> a = MagicMock()
>>> a.foo("hello")
<mock.MagicMock object at 0xa40cecc>
>>> a.foo("goodbye")
<mock.MagicMock object at 0xa40cecc>
>>> a.foo.call_args_list
[(('hello',), {}), (('goodbye',), {})]
>>> a.foo.call_args_list[0]
(('hello',), {})
>>> a.foo.call_args_list[0][0]
('hello',)
>>> a.foo.call_args_list[0][0][0]
'hello'
# New version:
>>> from mock import MagicMock
>>> a = MagicMock()
>>> a.foo("hello")
<mock.MagicMock object at 0x9f704ec>
>>> a.foo("goodbye")
<mock.MagicMock object at 0x9f704ec>
>>> a.foo.call_args_list
[(('hello',), {}), (('goodbye',), {})]
>>> a.foo.call_args_list[0]
(('hello',), {})
>>> a.foo.call_args_list[0][0]
''
>>> a.foo.call_args_list[0][0][0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: string index out of range
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment