ËÓùý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 code:
while not self._stopevent.isSet( ):
re=¶ÁȡϲãÏûÏ¢
if re>0:
´¦Àí
else:
pass
¼ÙÈ ......
ÎÒÏëÓÃpythonд·þÎñ¶Ë£¬C#д¿Í»§¶Ë£¬ÁíÍâÏë°Ñ¿Í»§¶ËC#ÖеĶÔÏóÐòÁл¯ºó´«¸ø·þÎñ¶Ë£¬ÓÃpython·´ÐòÁл¯ºóÖØ½¨¶ÔÏ󣬲»ÖªµÀÓÐûÓÐÕâ¸ö¿ÉÄÜ£¿Èç¹ûÓпÉÄÜÄÜ·ñÌṩ¸ö˼·£¿
Ò»ÇнÔÓпÉÄÜ¡£
˼·ÄãÒѾ˵µÄͦÇå³þµÄÁË¡£ ......
¸÷λ¸ßÊÖ£¬ÄÄλÄÜд¸ö¼òµ¥µÄͨѶ¼£¬Ö»±£´æÐÕÃûºÍÊÖ»úºÅ£¬Äܱ£´æµ½Ó²Å̲¢¿É¶Á»Ø£¬ÓÐÌí¼Ó£¬É¾³ý£¬Ð޸쬲éѯ¹¦ÄÜ£¬ÃüÁîÐÐʽµÄ¾ÍÐÐ
ÕâÖÖ»îÄãµÃ×Ô¼º¸É£¬ÓÐÎÊÌâ¿ÉÒÔÎÊ£¬µ«²»»áÓÐÈ˰ïÄã×öµÄ¡£
¸øÄãÔ´Âë
http://dow ......
//ÏÂÃæµÄ´úÂëÔËÐÐÕý³£
tomstrs=re.findall(......)
mtxx=''
for tomstr in tomstrs:
tomstr=tomstr.strip()
if tomstr:
mtxx += tomstr ......