Closed GoogleCodeExporter closed 9 years ago
You're syntax is slightly incorrect (which is why it's better to use the call
object instead of manually constructing tuples).
This "([1,])" is not a tuple containing a list - your comma is in the wrong
place. It should be "([1],)".
See the example below:
>>> import mock
>>> m = mock.Mock()
>>> m(1)
<Mock name='mock()' id='4299865232'>
>>> m([1])
<Mock name='mock()' id='4299865232'>
>>> m.call_args_list
[call(1), call([1])]
>>> m.call_args_list == [((1,), ), (([1,]), )]
False
>>> m.call_args_list == [((1,), ), (([1,],), )]
True
>>> call = mock.call
>>> m.call_args_list == [call(1), call([1])]
True
Original comment by fuzzyman
on 11 May 2012 at 2:44
Thanks for your explanation, I see my mistake!
As you say it's better to use the call objects anyway. Any idea though why this
evaluates to True:
>>> m.call_args_list == [((1,), ), [(([1,]), )]]
True
Original comment by grimmym...@gmail.com
on 11 May 2012 at 10:52
For individual calls, mock doesn't care whether it is a tuple or a list - it
just unpacks them and looks at the contents.
[(([1,]), )] is the same as [([1], )] which is roughly-sort-of-basically what you wanted in the first place...
Original comment by fuzzyman
on 11 May 2012 at 10:56
That is true.
Thank you very much for your help. Keep up the good work!
Original comment by grimmym...@gmail.com
on 12 May 2012 at 7:30
Original issue reported on code.google.com by
grimmym...@gmail.com
on 9 May 2012 at 1:13