【发布时间】:2010-09-22 15:59:02
【问题描述】:
我需要测试一个需要使用 urllib.urlopen 查询外部服务器上的页面的函数(它也使用 urllib.urlencode)。服务器可能已关闭,页面可能会更改;我不能依赖它进行测试。
控制 urllib.urlopen 返回什么的最佳方法是什么?
【问题讨论】:
-
不太一样,但我猜大多数人使用
requests:How can I mock requests and the response?
标签: python unit-testing testing mocking