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 Adnan Umer
Recipients Adnan Umer
Date 2018-12-24.15:19:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1545664740.73.0.712150888896.issue35577@roundup.psfhosted.org>
In-reply-to
Content
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 some_function(x):
    cls = SomeClass()
    y = class.do_something(x)
    return y


And the test for some_function will be 


def do_something_side_effect(x):
    retrun x

def test_some_function():
    with mock.path("SomeCass.do_something") as do_something_mock:
        do_something_mock.side_effect = do_something_side_effect
        assert some_function(1)


Here do_something_side_effect mock will not have access to SomeClass instance.
History
Date User Action Args
2018-12-24 15:19:03Adnan Umersetrecipients: + Adnan Umer
2018-12-24 15:19:00Adnan Umersetmessageid: <1545664740.73.0.712150888896.issue35577@roundup.psfhosted.org>
2018-12-24 15:19:00Adnan Umerlinkissue35577 messages
2018-12-24 15:19:00Adnan Umercreate