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.

Author ncoghlan
Recipients Ilya.Kulakov, giampaolo.rodola, ncoghlan, thehesiod, veky, yselivanov
Date 2017-08-20.04:07:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1503202057.32.0.403402930402.issue29302@psf.upfronthosting.co.za>
In-reply-to
Content
While it *may* be possible to do something simpler for test purposes where performance isn't a major concern, fully supporting type() level mocking basically requires bringing the equivalent of wrapt object proxies into the standard library: https://wrapt.readthedocs.io/en/latest/wrappers.html#object-proxy

I actually think we *should* do that, and occasionally bug Graham Dumpleton about it, but while he's not opposed to the idea, it's also something that would take quite a bit of work (since odd edge cases that are tolerable in an opt-in third party module would probably need to be addressed for a standard library version).

For test cases like AsyncExitStack though, we instead just use custom type definitions, rather than the unittest.mock module.

Autospec'ed mocks are most attractive when we're dealing with object interfaces that are subject to a high rate of churn (since they make the tests more self-adjusting), and that isn't the case here: Python's syntactic support protocols rarely change, and when they do, preserving backwards compatibility with existing classes is typically a key requirement.
History
Date User Action Args
2017-08-20 04:07:37ncoghlansetrecipients: + ncoghlan, giampaolo.rodola, yselivanov, thehesiod, veky, Ilya.Kulakov
2017-08-20 04:07:37ncoghlansetmessageid: <1503202057.32.0.403402930402.issue29302@psf.upfronthosting.co.za>
2017-08-20 04:07:37ncoghlanlinkissue29302 messages
2017-08-20 04:07:36ncoghlancreate