2024-10-01 04:53:13 发布
网友
我使用的是python“请求”,它工作得很好,但是现在我希望能够“模拟”响应,而不是接触真正的服务器。在
我这样做:
r = requests.get(self.url+'/somepath', params=payload)
在guzzlephp中,我可以这样做:
在请求或python中有类似的东西吗?在
谢谢!在
你可以用这个图书馆 https://requests-mock.readthedocs.io/en/latest/index.html做一些类似的事情
>>> import requests >>> import requests_mock >>> with requests_mock.Mocker() as m: ... m.get(self.url+'/somepath', text='mocked response') ... requests.get(self.url+'/somepath').text ... 'mocked response'
你可以用这个图书馆 https://requests-mock.readthedocs.io/en/latest/index.html做一些类似的事情
相关问题 更多 >
编程相关推荐