Issue 17502: unittest.mock: side_effect iterators ignore DEFAULT (original) (raw)

Issue17502

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.

This issue has been migrated to GitHub: https://github.com/python/cpython/issues/61704

classification

Title: unittest.mock: side_effect iterators ignore DEFAULT
Type: behavior Stage: resolved
Components: Versions: Python 3.3, Python 3.4

process

Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: michael.foord Nosy List: Chaka_bum, asvetlov, michael.foord, python-dev, raduv
Priority: normal Keywords: easy, patch

Created on 2013-03-21 03:05 by michael.foord, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue_17502.patch Chaka_bum,2013-04-07 12:46 review
Messages (7)
msg184836 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2013-03-21 03:05
An iterator set as a mock side_effect should be able to include mock.DEFAULT to use the standard return value. def test_side_effect_iterator_default(self): mock = Mock(return_value=2) mock.side_effect = [1, DEFAULT] result = mock(), mock() self.assertEqual(result, (1, 2))
msg185074 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2013-03-23 19:03
There's a straightforward patch here, it just needs applying: http://code.google.com/p/mock/issues/attachmentText?id=190&aid=1900000000&name=mock.patch&token=6pDNkNBcNLDftg-PsUE8roPb6T4%3A1363712167613
msg186202 - (view) Author: Yuriy Senko (Chaka_bum) * Date: 2013-04-07 12:46
Patch ported from http://code.google.com/p/mock/issues/attachmentText?id=190&aid=1900000000&name=mock.patch&token=6pDNkNBcNLDftg-PsUE8roPb6T4%3A1363712167613
msg186207 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2013-04-07 13:44
Fixed. Thanks
msg186282 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2013-04-08 09:57
This was committed without NEWS entry or documentation update.
msg186287 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-04-08 10:19
New changeset 4d8e9c5ba651 by Andrew Svetlov in branch '3.3': Add NEWS entry for #17502: Process DEFAULT values in mock side_effect that returns iterator. http://hg.python.org/cpython/rev/4d8e9c5ba651 New changeset f82fb8813407 by Andrew Svetlov in branch 'default': Add NEWS entry for #17502: Process DEFAULT values in mock side_effect that returns iterator. http://hg.python.org/cpython/rev/f82fb8813407
msg186288 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2013-04-08 10:20
NEWS updated, thanks.
History
Date User Action Args
2022-04-11 14:57:43 admin set github: 61704
2013-04-08 10:20:08 asvetlov set messages: +
2013-04-08 10:19:18 python-dev set nosy: + python-devmessages: +
2013-04-08 09:57:32 michael.foord set messages: +
2013-04-07 13:44:45 asvetlov set status: open -> closedresolution: fixedmessages: + stage: needs patch -> resolved
2013-04-07 12:46:44 Chaka_bum set files: + issue_17502.patchnosy: + Chaka_bum, asvetlovmessages: + keywords: + patch
2013-03-27 23:37:45 raduv set nosy: + raduv
2013-03-23 19:03:51 michael.foord set messages: +
2013-03-21 03:05:40 michael.foord create