bpo-38932: Make Mock.reset_mock() pass return_value and side_effect values to reset_mock on child mock objects#17409
bpo-38932: Make Mock.reset_mock() pass return_value and side_effect values to reset_mock on child mock objects#17409cjw296 merged 3 commits intopython:masterfrom vegarsti:fix-issue-38932
Conversation
|
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! |
cjw296
left a comment
There was a problem hiding this comment.
This looks good to go but you need to add the NEWS entry.
|
@cjw296: Great, thanks! Will do! |
Issue on issue tracker.
The
Mockclass fromunittesthas a methodreset_mock, which takes optional argumentsreturn_valueandside_effect, both with default valuesFalse.In the body of
reset_mock,reset_mockis called recursively on all the_mock_childrenof theMockobject. 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
Mockobject with children that are also mocked, and methods on these have been directly mocked, then it is not enough to callreset_mockon 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