
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2016-04-13 22:13 byamaury.forgeotdarc, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.
| 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)*![]() | 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)*![]() | Date: 2016-05-18 11:47 | |
Updated patch with review comments. | |||
| msg272122 -(view) | Author: Roundup Robot (python-dev)![]() | Date: 2016-08-07 16:06 | |
New changesete947248100ae by Gregory P. Smith in branch '3.5':Issue#26750: unittest.mock.create_autospec() now works properlyhttps://hg.python.org/cpython/rev/e947248100aeNew changeset0bc14c91ef7e by Gregory P. Smith in branch 'default':Issue#26750: unittest.mock.create_autospec() now works properly forhttps://hg.python.org/cpython/rev/0bc14c91ef7e | |||
| msg272124 -(view) | Author: Berker Peksag (berker.peksag)*![]() | 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)*![]() | 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)![]() | Date: 2016-08-16 06:56 | |
New changeset3ff02380b1bf by Gregory P. Smith in branch '3.5':Issue#26750: use inspect.isdatadescriptor instead of our ownhttps://hg.python.org/cpython/rev/3ff02380b1bfNew changesetd51a66622266 by Gregory P. Smith in branch 'default':Issue#26750: use inspect.isdatadescriptor instead of our ownhttps://hg.python.org/cpython/rev/d51a66622266 | |||
| msg272997 -(view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc)*![]() | 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 | |