This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author michael.foord
Recipients gregory.p.smith, michael.foord
Date 2013-04-26.11:35:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1366976113.36.0.466008156956.issue17826@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-04-26 11:35:13michael.foordsetrecipients: + michael.foord, gregory.p.smith
2013-04-26 11:35:13michael.foordsetmessageid: <1366976113.36.0.466008156956.issue17826@psf.upfronthosting.co.za>
2013-04-26 11:35:13michael.foordlinkissue17826 messages
2013-04-26 11:35:13michael.foordcreate