所以我已经安装了pymox,我想测试一下这个方法:
class HttpStorage():
def download(self, input, output):
try:
file_to_download = urllib2.urlopen(input)
except URLError:
raise IOError("Opening input URL failed")
f = open(output, "wb")
f.write(file_to_download.read())
f.close()
return True
我正在阅读pymox文档,但是我不知道如何去做。你能帮我一些示例代码吗?在
您可以尝试使用这种格式来测试下载功能,因为urllib2.openurl()被模拟为进行单元测试。在
相关问题 更多 >
编程相关推荐