Karthikeyan Singaravelan <tir.kar...@gmail.com> added the comment:

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

----------
nosy: +cjw296, mariocj89, xtreak
versions:  -Python 2.7, Python 3.4, Python 3.5, Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35577>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to