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 Dima.Tisnek, michael.foord, r.david.murray
Date 2014-10-03.03:48:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1412308108.33.0.275307826369.issue22541@psf.upfronthosting.co.za>
In-reply-to
Content
One of the use cases for side_effect is for dynamically changing the returned value based on input - so your option 1 just doesn't work.

Using two line functions would make your code easier to read, and then your "workarounds" would look natural instead of awkward.

Maybe return_value should take precedence over side_effect if both are set.

It would probably be more pythonic to raise an exception in that case - although that would be annoying if you're just reconfiguring a mock. I've also written side_effect functions that accessed the return_value, which is probably the genesis of the current API.

As you point out, both your suggested changes are backwards incompatible, so I'm closing this issue.
History
Date User Action Args
2014-10-03 03:48:28michael.foordsetrecipients: + michael.foord, r.david.murray, Dima.Tisnek
2014-10-03 03:48:28michael.foordsetmessageid: <1412308108.33.0.275307826369.issue22541@psf.upfronthosting.co.za>
2014-10-03 03:48:28michael.foordlinkissue22541 messages
2014-10-03 03:48:27michael.foordcreate