易截截图软件、单文件、免安装、纯绿色、仅160KB

谁用过python 的mock 做unit test

如果一段代码

Python code:

#!/usr/bin/python2.5

from urllib2 import Request,urlopen,URLError

def check():
req = Request('http://www.google.com')
try:
res = urlopen(req).read()
return res
except URLError, e:
if hasattr(e, 'reason'):
return('We failed to reach the server. Reason: %s' % e.reason)
elif hasattr(e, 'code'):
return('The server couldn\'t fulfill the request. Error code: %s' %
e.code)

if __name__ == '__main__':
print check()



现在我要做unit test 我怎么样能用mock 来做一些模拟的访问网络及异常处理?

友情帮顶

moke 能做什么?能在客户端执行js吗?



End_rbody_60020883//-->
该回复于2009-09-25 10:49:51被管理员删除



对我有用[0]
丢个板砖[0]
引用
举报
管理
TOP








相关问答:

关于python读列数据

a.txt
文件内容如下(其中空白部分都是以tab键隔开):

om 2 0.68 0.83 0 0 0 0 0 0
pos
ppa 17 0.74 0.9 0 0 0 1 2 2
ppc    2           & ......

请问python和pyodc有什么区别

麻烦高手解答一下 谢谢了 我是新手 一些概念都不太清楚。。。
pyodbc is a Python module that allows you to use ODBC to connect to almost any database from Windows, Linux, OS/X, and more.

pyodbc是 ......

[免费分享]Let's Python视频第二集发布, 可稳定下载.

喜欢Python的朋友请进.
详细信息请查看:
http://blog.csdn.net/lgg201/archive/2009/10/08/4643635.aspx

  Let's-python-系列视频发布专贴 收藏
视频较早的时候就说是要录了, 这一周录了 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号