[issue35577] side_effect mocked method lose reference to instance

2022-03-19 Thread Irit Katriel
Change by Irit Katriel : -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker ___ ___

[issue35577] side_effect mocked method lose reference to instance

2019-02-14 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan 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

[issue35577] side_effect mocked method lose reference to instance

2019-01-01 Thread Rémi Lapeyre
Rémi Lapeyre added the comment: Is there a problem with: from unittest import mock class SomeClass: def do_something(self, x): pass def some_function(x): obj = SomeClass() y = obj.do_something(x) return y def do_something_side_effect(self, x): print(self)

[issue35577] side_effect mocked method lose reference to instance

2018-12-24 Thread Adnan Umer
New submission from Adnan Umer : When a method/bounded function is mocked and side_effect is supplied to it, the side_effect function doesn't get the reference to the instance. Suppose we have something like this class SomeClass: def do_something(self, x): pass def