ËÓùý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+tkдÁËÒ»¸ö¼òµ¥½Å±¾£¬ÓÃÀ´ÏÔʾһЩͼƬºÍÆä˵Ã÷£¬Éè¼Æ2¸ö°´Å¥À´·Ò³¡£¿Ø¼þ²ÉÓÃpack()·½Ê½£¬Ö÷´°¿ÚûÓÐÌرðÖ¸¶¨³ß´ç£¬°´Ï·ҳ°´Å¥ºóÄÜ×Ô¶¯ÒÀ¾ÝÄÚÈÝ×Ô¶¯Ëõ·Å´óС£¬ÈçÔ¤ÆÚÉèÏë¡£²»¹ý±È½ÏÆæ¹ÖµÄÊÇ,Èç¹ûÓÃÊ ......
a.xmlÄÚÈÝÈçÏÂ:
</project>
<project name="asdf" branch="asfasdfas" naname="xiao xin" QD6="091010">
<compo ......
ÈçÌ⣡
www.Portablepython.com
ѧϰÁË
¹ÙÍø²»¾ÍÓÐÂð
»òÕß×Ô¼º±àÒëºÃÁË
Portablepython¾ÍÊÇ,Äã´ÓËüµÄ¹ÙÍøÉÏÏÂÔØÏÂÀ´,¿ÉÒÔ°ÑËü°²×°µ½´ÅÅÌÉÏ(ÓÈÆäÊÇ°²×°µ½UÅÌÉÏ,¿ÉÒÔËæÉí´ø×Å)
Portablepython ......
ʹÓÃÔ´Îļþ
#!/usr/bin/python
# Filename : helloworld.py
print 'Hello World'
ÎÒÔõôҲ¿´²»¶®£¡Ö»ÊÇ×îºóÒ»ÐÐÎÒÖªµÀ~~Ç°ÃæÁ½ÐÐÊÇʲôÒâ˼ÄØ£¿
½Ì³ÌÉÏ˵Èç¹ûÄãʹÓÃIDLE£¬ÇëʹÓò˵ ......
ϲ»¶PythonµÄÅóÓÑÇë½ø.
ÏêϸÐÅÏ¢Çë²é¿´:
http://blog.csdn.net/lgg201/archive/2009/10/08/4643635.aspx
Let's-python-ϵÁÐÊÓƵ·¢²¼×¨Ìù ÊÕ²Ø
ÊÓƵ½ÏÔçµÄʱºò¾Í˵ÊÇҪ¼ÁË, ÕâÒ»ÖܼÁË ......