-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
bpo-31177: Fix reset_mock on mock with deleted children #10807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
vstinner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change doesn't look correct to me. reset_mock() documentation says:
"The reset_mock method resets all the call attributes on a mock object"
https://docs.python.org/dev/library/unittest.mock.html#unittest.mock.Mock.reset_mock
I don't think that delete attributes are "call attributes".
cc @mariocj89
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
Absolutely agree with @vstinner If the feature of resetting deleted attributes is really needed, that would be separate from fixing the current issue and I'd add it in an optional way, the same way Additionally, this will still break for delted attributes in childs isn't it? |
|
Thanks for you comments. I'll make this PR just solve the immediate issue. |
|
I have made the requested changes; please review again. |
|
Thanks for making the requested changes! @vstinner: please review the changes made to this pull request. |
|
@vstinner, the changes I made are visible in my repo, but not here. I hoped using the "I've made the changes" message above would help them appear, but that doesn't seem to be the case. |
|
@vstinner, I figured out my error. I have to open a new PR because I can't change the source branch. |
Currently, calling reset_mock() on a unittest.mock.Mock object after one of its attributes was deleted causes an exception.
This fixes the exception and introduces the behavior that the deletion of the attribute is reset, making it available again after the reset_mock() call.
https://bugs.python.org/issue31177