-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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.patch could whitelist builtins to not need create=True #61860
Comments
When patching builtin names (e.g. open) in a specific namespace you need to specify "create=True" or patch will refuse to create a name that doesn't exist. patch could whitelist the builtin names, when the patch target is a module object, to not require the "create=True". |
Working on this. |
Initial patchset along with documentation and tests update. |
To be honest this proposal sounds like a quirk more than a feature to me. If you only special-case builtins, people will have to remember that special case and it will make the API more complicated. |
I don't think that's a particular issue. In general you only need to use "create=True" if a name is *not* available in a namespace. Builtin names are odd in that you can use them in a namespace even though they don't exist there - so you have to *remember* to use "create=True" even though the name *is* available. So this issue is about fixing that quirk. |
Reviewed on Rietveld. |
Updated patch with builtins module. |
New changeset e457de60028c by Michael Foord in branch 'default': |
+ .. note:: I think using a note directive is not necessary here. Also it looks a bit ugly :) https://dl.dropboxusercontent.com/u/166024/issue17660.png
|
Personally I don't think it looks ugly and that it is a point worth calling out. Other opinions welcomed. |
I noticed this in the commit; I don’t think the rendered output is really ugly, but the markup does look strange, as it’s two nested note(-like) directives. |
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: