Best Python code snippet using lemoncheesecake
runner.py
Source:runner.py
1# coding=utf-82"""3using method:4 input command in cmd linke "python runner.py case_2 case_1"5"""6import os7import sys8import time9import datetime10from importlib import reload11__author__ = "zzh"12# å½åè·¯å¾13path = os.path.abspath(__file__)14path = os.path.dirname(path)15print(path)16sys.path.insert(0, path + "/../../")17sys.path.insert(0, '..')18print(sys.path)19from runners.runner import get_suites20from runners.runner import report_parse21from runners.runner import HTMLTestRunner22from utils.global_var import GlobalVarClass23from utils.ding_msg_send import DingMsgSend24# è·åå½åæ¶é´ï¼ç»ææ件å25date = time.strftime("%Y%m%d", time.localtime()) # æ¥æã20150213ã26timestamp = str(int(time.time())) # æ¶é´æ³ã1423813170ã27report_file_name = date + timestamp + '.html'28if GlobalVarClass.get_now_time() == "":29 now_time = str(datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d_%H_%M_%S'))30 GlobalVarClass.set_now_time(now_time)31def run_test_cases(test_sets, report_dir, report_title):32 """33 è¿è¡æµè¯ç¨ä¾34 test_setsï¼åå
¸æ ¼å¼çæµè¯é35 """36 # å¤ææ¥åæ件夹æ¯å¦åå¨ï¼è¥ä¸åå¨åå建37 is_exist = os.path.exists(report_dir)38 if is_exist is False:39 os.makedirs(report_dir)40 # æå®æµè¯é41 root = os.path.dirname(os.path.abspath(__file__)) + "/../../testcases"42 test_suites = get_suites.generate_suites(root, test_sets) # åªè¿è¡æå®æµè¯ç¨ä¾é43 # test_suites = nose.collector() # è¿è¡å
¨é¨ç¨ä¾44 # å®ä¹æ¥åå称45 file_path = report_dir + '/' + report_file_name46 print("æ¥åç®å½" + file_path)47 fp = open(file_path, 'wb')48 runner = HTMLTestRunner.HTMLTestRunner(49 stream=fp,50 title=report_title # å¦ï¼'å
±äº«å¹³å°æ¥å£æµè¯[ApiTest for SDP]'51 )52 runner.run(test_suites)53def get_report_path(report_file):54 """55 æ ¹æ®é
ç½®çæ件ç»æï¼çææ件路å¾56 pathï¼å½åè·¯å¾57 """58 tmp = report_file.split('.')59 report_file_path = "test_reports"60 for i in tmp:61 report_file_path += "/"62 report_file_path += i63 report_dir = path + "/../../" + report_file_path64 return report_dir65if __name__ == "__main__":66 case_list = get_suites.set_case_list() # è·åååçæµè¯éä¿¡æ¯å表67 if case_list is None:68 print("case_list is empty")69 exit()70 for case_info in case_list:71 # print "case_info: ", case_info72 report_file_dir = case_info[u'report_file']73 test_sets = case_info[u'cases']74 receivers = case_info[u'receivers']75 group = case_info[u'group']76 title = case_info[u'title']77 report_dir = get_report_path(report_file_dir)78 run_test_cases(test_sets, report_dir, title)79 res = report_parse.get_result(report_dir, title, report_file_name, date, timestamp)80 ding_send_msg = DingMsgSend(group[0])81 ding_send_msg.send_msg(res)82 # for g in group:83 # receivers.append(g)84 # mail = Mail()85 # mail.subject = "UIèªå¨åæµè¯ç»æ"86 # mail.mail_to = receivers87 # mail.send_mail(res)...
suites.py
Source:suites.py
...21 client.user = 'dmitriy.zverev@homecredit.ru'22 client.password = 'Qwerty_22'23 case = client.send_get('get_suite/51')24 pprint(case)25def get_suites():26 """27 Ð ÑÑка Ð´Ð»Ñ Ð¿Ð¾Ð»ÑÑÐµÐ½Ð¸Ñ Ð¸Ð½ÑоÑмаÑии о ÑÑÑÑаÑ
в пÑоекÑе.28 ÐÑ
одÑÑий паÑамеÑÑ: project_id29 """30 client = APIClient('https://testrail.homecred.it')31 client.user = 'dmitriy.zverev@homecredit.ru'32 client.password = 'Qwerty_22'33 case = client.send_get('get_suites/5')34 pprint(case)35def update_suite():36 """37 Ð ÑÑка Ð´Ð»Ñ Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ñ ÑÑÑеÑÑвÑÑÑего ÑÑÑÑа.38 ÐÑ
одÑÑий паÑамеÑÑ: suite_id39 Data: name...
sous_suite_monotone.py
Source:sous_suite_monotone.py
...9 """Renvoie les nombres du (ou des) fichier(s) dans une seule liste10 """11 with open(sys.argv[1], 'r') as file:12 return iter(file.read().split())13def get_suites():14 """Renvoie les suites monotones15 """16 numbers = get_numbers()17 suite = [next(numbers, None)]18 monotonie = None19 while numbers:20 try:21 first = suite[-1]22 second = next(numbers)23 #print("second", second)24 if second < first:25 #print("décroissante")26 if monotonie: #détecte le changement de monotonie27 yield suite28 suite = [first]29 suite.append(second)30 #print(suite)31 monotonie = 032 elif second > first:33 #print("croissante")34 if not monotonie: #détecte le changement de monotonie35 yield suite36 suite = [first]37 suite.append(second)38 #print(suite)39 monotonie = 140 elif second == first:41 suite.append(second)42 #print(suite)43 else:44 yield suite45 suite = [first]46 except StopIteration:47 yield suite48 break49def get_max_suite():50 """Get the biggest sequence51 """52 return max([suite for suite in get_suites()], key=len)53def main():54 """main function55 """56 biggest_suite = get_max_suite()57 print(biggest_suite)...
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!!