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
Mock autospec does not work with subclasses of property() #70937
Comments
When patching a class, mock.create_autospec() correctly detects properties and __slot__ attributes, but not subclasses of property() or other kinds of data descriptors. The attached patch detects all data descriptors and patch them the way they should be. |
Updated patch with review comments. |
New changeset e947248100ae by Gregory P. Smith in branch '3.5': New changeset 0bc14c91ef7e by Gregory P. Smith in branch 'default': |
Thanks! Is there a reason not to use inspect.isdatadescriptor() instead of _is_data_descriptor()? |
Probably just Amaury and I forgetting that existed. Amaury, inspect.isdatadescriptor's implementation is a bit different than this change's _is_data_descriptor. Thoughts? |
New changeset 3ff02380b1bf by Gregory P. Smith in branch '3.5': New changeset d51a66622266 by Gregory P. Smith in branch 'default': |
inspect.isdatadescriptor() is better indeed.
IOW, I'm happy with the current state. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: