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.

Title: reset_mock needs parameters to also reset return_value and side_effect
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.5
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: michael.foord Nosy List: Claudiu.Popa, berker.peksag, kushal.das, michael.foord, python-dev
Priority: normal Keywords: patch

Created on 2014-04-16 20:51 by michael.foord, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit
issue21271.patch kushal.das, 2015-04-14 13:58 New parameters for reset_mock review
issue21271v2.patch kushal.das, 2015-04-14 15:25 Version 2 of the patch review
Messages (7)
msg216588 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2014-04-16 20:51
unittest.mock.Mock.reset_mock deliberately doesn't reset the return_value and side_effect. It would be nice if it gained parameters so that it *could*.
msg240585 - (view) Author: Kushal Das (kushal.das) * (Python committer) Date: 2015-04-13 02:25
Working on it. Will submit the patch tomorrow.
msg240888 - (view) Author: Kushal Das (kushal.das) * (Python committer) Date: 2015-04-14 13:58
A patch without NEWS and whatsnew update. I will fill them before commit.

The reset_mock function now has two parameters, return_value, and side_effect. Passing True value to any of these will reset that attribute.
msg240890 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2015-04-14 14:12
I left a couple of comments of Rietveld.
msg240906 - (view) Author: Kushal Das (kushal.das) * (Python committer) Date: 2015-04-14 15:25
Updated patch with the suggestions from Berker.
msg266895 - (view) Author: Kushal Das (kushal.das) * (Python committer) Date: 2016-06-02 17:23
Fixed in
msg266896 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-02 17:29
New changeset b110dd3d6cea by Kushal Das in branch 'default':
Issue #21271: Adds new keyword only parameters in reset_mock call
Date User Action Args
2022-04-11 14:58:02adminsetgithub: 65470
2016-06-02 17:29:18python-devsetnosy: + python-dev
messages: + msg266896
2016-06-02 17:26:50abarrysetresolution: fixed
stage: patch review -> resolved
2016-06-02 17:23:44kushal.dassetstatus: open -> closed

messages: + msg266895
2015-04-14 15:25:25kushal.dassetfiles: + issue21271v2.patch

messages: + msg240906
2015-04-14 14:12:08berker.peksagsetnosy: + berker.peksag
messages: + msg240890

type: behavior -> enhancement
stage: needs patch -> patch review
2015-04-14 13:58:03kushal.dassetfiles: + issue21271.patch
keywords: + patch
messages: + msg240888
2015-04-13 02:25:17kushal.dassetmessages: + msg240585
2015-03-09 14:40:57Claudiu.Popasetnosy: + Claudiu.Popa
2014-04-16 20:51:44michael.foordcreate