Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upbpo-38932: Make Mock.reset_mock() pass return_value and side_effect values to reset_mock on child mock objects #17409
Conversation
This comment has been minimized.
This comment has been minimized.
the-knights-who-say-ni
commented
Nov 27, 2019
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). CLA MissingOur records indicate the following people have not signed the CLA: For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. If you have recently signed the CLA, please wait at least one business day You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
This looks good to go but you need to add the NEWS entry. |
This comment has been minimized.
This comment has been minimized.
@cjw296: Great, thanks! Will do! |
aef7dc8
into
python:master
vegarsti commentedNov 27, 2019
•
edited by bedevere-bot
Issue on issue tracker.
The
Mock
class fromunittest
has a methodreset_mock
, which takes optional argumentsreturn_value
andside_effect
, both with default valuesFalse
.In the body of
reset_mock
,reset_mock
is called recursively on all the_mock_children
of theMock
object. However, here the arguments are not passed. I realize this may be a feature and not a bug, but this caused some confusion in the test suite at the company where I work, where we thought we reset our mocked objects properly, but we didn't.This means that if you have a
Mock
object with children that are also mocked, and methods on these have been directly mocked, then it is not enough to callreset_mock
on the parent object.This is my first attempt at a contribution to Python. I have most likely done something wrong, and I will do my best to help further.
https://bugs.python.org/issue38932