Author xtreak
Recipients Adnan Umer, cjw296, mariocj89, remi.lapeyre, xtreak
Date 2019-02-14.18:04:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1550167449.72.0.301070443858.issue35577@roundup.psfhosted.org>
In-reply-to
Content
Thanks for the report. I think this is design by choice that self is not passed to the side_effect directly set on the mock [0]. Changing this would break existing tests like [1] . You can use the approach by @remi.lapeyre which directly replaces the function on the target inside the context manager at [2] passing self to the side_effect callable.

[0] https://github.com/python/cpython/blob/8a1657b93469580ef345c7c91738587f3d76e87d/Lib/unittest/mock.py#L1043
[1] https://github.com/python/cpython/blob/8a1657b93469580ef345c7c91738587f3d76e87d/Lib/unittest/test/testmock/testmock.py#L664
[2] https://github.com/python/cpython/blob/8a1657b93469580ef345c7c91738587f3d76e87d/Lib/unittest/mock.py#L1376
History
Date User Action Args
2019-02-14 18:04:09xtreaksetrecipients: + xtreak, cjw296, mariocj89, remi.lapeyre, Adnan Umer
2019-02-14 18:04:09xtreaksetmessageid: <1550167449.72.0.301070443858.issue35577@roundup.psfhosted.org>
2019-02-14 18:04:09xtreaklinkissue35577 messages
2019-02-14 18:04:09xtreakcreate