How to unit test code that makes HTTP requests with twisted.web.client.Agent?

帅比萌擦擦* 提交于 2019-12-04 13:27:44

it is certainly possible to use a real Agent. You must construct the Agent instance with a reactor as first argument; as such, you can provide a fake reactor, such as MemoryReactor. Although that's a pretty handy way to get down in the guts of what Agent is doing, it's really mostly useful for testing Agent itself. Injecting a fake Agent is many times an easier route, because its api is both shallow (almost everything passes through Agent.request and simple (it returns an IResponse)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!