擅长:python、mysql、java
<p>您可以向请求发送两次要模拟的不同数据,它将模拟该方法并返回在return_value中指定的预期数据</p>
<pre><code>@patch('the_function_path_you_want_to_mock')
def test_data(self, mock_obj):
mock_obj.return_value.function_to_be_mocked.return_value = [data_to_mocked]
response = self.client.post('/request', data=json.dumps(self.input_data), content_type='application/vnd.api+json', )
mock_obj.return_value.function_to_be_mocked.return_value = [data_to_mocked]
response = self.client.post('/request', data=json.dumps(self.input_data), content_type='application/vnd.api+json', )
</code></pre>