Best Python code snippet using autotest_python
getFriendsWeibo.py
Source:getFriendsWeibo.py
1# -*- coding: UTF-8 -*- 2'''3Created on 2013-12-124@author: Hao5'''6# import jieba7# import pymongo8from getAccessToken import getAcc9from userSpammerDetect import detector10from filterComment import filterWeibo11# åæç´¢12# seg_list = jieba.cut("ææ¥å°å京æ¸
å大å¦",cut_all=True) 13# print "Full Mode:", "/ ".join(seg_list) #å
¨æ¨¡å¼ 14client = getAcc().accessToken_get()15#建ç«mongoDBè¿æ¥16# conn = pymongo.Connection('localhost',27017)17# db = conn.test18# dbCollection = db.weibo19# å¾å°å
³æ³¨çå¾®å20status = client.statuses.friends_timeline.get()21get_statuses = status.__getattr__('statuses')22# type(get_statuses)23#è¾åºæ¯ä¸æ¡å¾®å以åå¾®åçè¯è®º24for count in range(len(get_statuses)):25# for count in range(5):26 print "~~~~~~~~~ä¸æ¡æ°å¾®å~~~~~~~~~~~~~"27 weibo = get_statuses[count]['text']28 print "weibo: " + str(weibo)29 30 messageid = get_statuses[count]['mid']31 commentCount = 032 while True:33 comments = client.comments.show.get(id=messageid, count=200, page=commentCount/200+1)34# seg_list = jieba.cut(comments, cut_all=False)35# print "| ".join(seg_list) 36 37 get_comments_status = comments.__getattr__('comments')38 numberOfSpammer = 039 numberOfReal = 040 for i in range(len(get_comments_status)):41 comment = get_comments_status[i]['text']42 print "origin comment: "+comment43 print "comment: "+filterWeibo().filtering(comment)44 userInfo = get_comments_status[i]['user']45 result = detector().detect(userInfo)46 if result:47 print "ä¸å¥åº·ç¨æ·"48 numberOfSpammer+=149 else:50 print "çå®ç¨æ·"51 numberOfReal+=152 53 commentCount+=20054 comments.__getattr__('total_number')55 totalComment = comments['total_number']56 print str(commentCount)+"--è¯è®ºæ°"+" æ»å
±æï¼"+str(totalComment)57 if commentCount>=totalComment:58 break;59# åå
¥mongoDB60# dbCollection.insert({"weibo":get_statuses[count],"count":count,"comments":comments, "numberOfSpammer":numberOfSpammer, "numberOfReal":numberOfReal})...
test_commit.py
Source:test_commit.py
...8 'get_statuses': lambda self: self.statuses,9 'statuses': []})10 commit = CommitMock()11 commit.pending()12 assert commit.get_statuses()[0].context == 'review/gitmate/manual'13 commit.ack()14 assert commit.get_statuses()[1].status == Status.SUCCESS15 commit.unack()16 assert commit.get_statuses()[2].status == Status.FAILED17 commit.pending()...
constants.py
Source:constants.py
...7SCREEN = pg.display.set_mode((WIDTH, HEIGHT))8IMG_FOLDER = 'img'# os.path.join('img','player')9BG = (144, 201, 120)10RED = (144, 0, 0)11PLAYER_STATUSES = get_statuses(os.path.join(IMG_FOLDER, 'player'))12ENEMIES_STATUSES = get_statuses(os.path.join(IMG_FOLDER, 'enemy'))13BULLET_IMG = os.path.join(IMG_FOLDER, 'bullets_and_grenades','bullet.png')14GRENADE_IMG = os.path.join(IMG_FOLDER, 'bullets_and_grenades','grenade.png')15EXPLOSION_STATUSES = get_statuses(os.path.join(IMG_FOLDER, 'explosion'))16IDLE_ANIMATION_COOLDOWN = 9017JUMP_ACTION_COOLDOWN = 4018GRAVITY = 0.98119GROUD_LINE = HEIGHT // 2...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!