This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2016年04月13日 22:13 by amaury.forgeotdarc, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| mock-descriptor.patch | amaury.forgeotdarc, 2016年04月13日 22:13 | review | ||
| mock-descriptor-2.patch | amaury.forgeotdarc, 2016年05月18日 11:47 | review | ||
| Messages (7) | |||
|---|---|---|---|
| msg263361 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) | Date: 2016年04月13日 22:13 | |
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. |
|||
| msg265827 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) | Date: 2016年05月18日 11:47 | |
Updated patch with review comments. |
|||
| msg272122 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2016年08月07日 16:06 | |
New changeset e947248100ae by Gregory P. Smith in branch '3.5': Issue #26750: unittest.mock.create_autospec() now works properly https://hg.python.org/cpython/rev/e947248100ae New changeset 0bc14c91ef7e by Gregory P. Smith in branch 'default': Issue #26750: unittest.mock.create_autospec() now works properly for https://hg.python.org/cpython/rev/0bc14c91ef7e |
|||
| msg272124 - (view) | Author: Berker Peksag (berker.peksag) * (Python committer) | Date: 2016年08月07日 16:38 | |
Thanks! Is there a reason not to use inspect.isdatadescriptor() instead of _is_data_descriptor()? |
|||
| msg272215 - (view) | Author: Gregory P. Smith (gregory.p.smith) * (Python committer) | Date: 2016年08月09日 04:40 | |
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? |
|||
| msg272842 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2016年08月16日 06:56 | |
New changeset 3ff02380b1bf by Gregory P. Smith in branch '3.5': Issue #26750: use inspect.isdatadescriptor instead of our own https://hg.python.org/cpython/rev/3ff02380b1bf New changeset d51a66622266 by Gregory P. Smith in branch 'default': Issue #26750: use inspect.isdatadescriptor instead of our own https://hg.python.org/cpython/rev/d51a66622266 |
|||
| msg272997 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) | Date: 2016年08月17日 22:37 | |
inspect.isdatadescriptor() is better indeed. (I was initially working on an old version of mock.py which does not import inspect, and I did not want to add the dependency there). - inspect uses hasattr(type(obj)) instead of hasatr(obj). This is better, (but does not work for 2.x old-style classes) - my patch tested for __del__... this is completely wrong, it should have been __delete__. oops. inspect.isdatadescriptor() does not test for __delete__. This is insaccurate, but I doubt it will ever matter. This is only possible for Python-defined descriptors, the C implementation always exposes both __set__ and __delete__ when tp_set is filled. IOW, I'm happy with the current state. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:29 | admin | set | github: 70937 |
| 2016年08月17日 22:40:09 | gregory.p.smith | set | stage: commit review -> resolved |
| 2016年08月17日 22:37:19 | amaury.forgeotdarc | set | messages: + msg272997 |
| 2016年08月16日 06:56:41 | python-dev | set | messages: + msg272842 |
| 2016年08月09日 04:40:38 | gregory.p.smith | set | messages:
+ msg272215 stage: resolved -> commit review |
| 2016年08月07日 16:38:35 | berker.peksag | set | messages:
+ msg272124 stage: commit review -> resolved |
| 2016年08月07日 16:07:15 | gregory.p.smith | set | status: open -> closed resolution: fixed stage: patch review -> commit review |
| 2016年08月07日 16:06:41 | python-dev | set | nosy:
+ python-dev messages: + msg272122 |
| 2016年08月07日 14:43:22 | gregory.p.smith | set | nosy:
+ gregory.p.smith |
| 2016年05月18日 11:49:07 | berker.peksag | set | assignee: berker.peksag |
| 2016年05月18日 11:47:01 | amaury.forgeotdarc | set | files:
+ mock-descriptor-2.patch messages: + msg265827 |
| 2016年04月21日 11:51:38 | berker.peksag | set | versions:
+ Python 3.5, Python 3.6 nosy: + berker.peksag components: + Library (Lib), - Tests type: enhancement -> behavior stage: patch review |
| 2016年04月13日 22:13:06 | amaury.forgeotdarc | create | |