I am testing a Python method which makes an HTTP request to a server. The method looks like this:
def do_something():
data = get_data()
make_request(data)
def make_request(self, data):
self.send_response(200)
self.wfile.write(json.dumps(msg))
From my test, I want to assert based on the data variable. I don't want to touch the production code (i.e., I don't want to make the method return the data explicitly). Is there a way I can mock out the make_request method, but return the params as the return value? Something like:
service.make_request = MagicMock(return_value=params)