I have a function called get_account(param1,param2) in run time I need to replace this function with the function mock_get_account(param1,param2) so when the system calls get_account(param1,param2) I need the mock_get_account(param1,param2) to be called instead.
I tried this code: package.get_account=self.mock_get_account package.get_account(x,y) but still the get_account runs instead of the mock_get_account I'm new to python and I don't know if this is even possible but I have seen the lamda function and I know that function programming is possible in python. Thanks Edit: if i do the following:
package.get_account=self.mock_get_account
package.get_account(x,y)
then every thing is ok, meaning the mock_get_account is called, but in mu code I the following code i do a post self.client.post(url, data=data, follow=True) that triggers the package.get_account and this is not working:
package.get_account=self.mock_get_account
package.get_account(x,y)
#the folowing call will trigger the package.get_account(x,y) function in a django url #callback
self.client.post(url, data=data, follow=True)
meaning it calls the old function, also get_account(param1,param2) is defined in side a file, and is not a child function of a class and mock_get_account(self,param1,param2) is defined in a class Test and is called inside the Test.test_account - function