Author cjw296
Recipients cjw296, michael.foord, ncoghlan, yselivanov
Date 2015-11-01.23:54:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1446422061.52.0.857294274427.issue25532@psf.upfronthosting.co.za>
In-reply-to
Content
A naive solution is to chat unittest.mock._Call's __getattr__ to be as follows:

def __getattr__(self, attr):
    if attr == '__wrapped__':
        raise AttributeError('__wrapped__')
    if self.name is None:
        return _Call(name=attr, from_kall=False)
    name = '%s.%s' % (self.name, attr)
    return _Call(name=name, parent=self, from_kall=False)

...but I'm not sure that's the right thing to do.

inspect.unwrap is trying to catch this loop, but the implementation fails for cases where f.__wrapped__ is generative, as in the case of Mock and _Call.

I suspect both modules need a fix, but not sure what best to suggest.
History
Date User Action Args
2015-11-01 23:54:21cjw296setrecipients: + cjw296, ncoghlan, michael.foord, yselivanov
2015-11-01 23:54:21cjw296setmessageid: <1446422061.52.0.857294274427.issue25532@psf.upfronthosting.co.za>
2015-11-01 23:54:21cjw296linkissue25532 messages
2015-11-01 23:54:21cjw296create