Michael Foord added the comment:

This illustrates the difference:

>>> from mock import Mock, create_autospec
>>> some_list = [1, 2, 3]
>>> m = Mock()
>>> m.side_effect = some_list
>>> m.side_effect
<listiterator object at 0x1004ab7d0>
>>> m2 = create_autospec(lambda: None)
>>> m2.side_effect = some_list
>>> m2.side_effect
[1, 2, 3]


When setting a side_effect on a function (created by create_autospec) the 
side_effect setter is not used - so turning the list into an iterator needs to 
be done on first use instead.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17826>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to