How to use fail_class method in avocado

Best Python code snippet using avocado_python

tronscanUI.py

Source:tronscanUI.py Github

copy

Full Screen

1import re2import os3import requests4import json5def ding(fail_class):6 mes = ""7 for i in fail_class:8 mes += "- " + i + "\n"9 webhook = "https://oapi.dingtalk.com/robot/send?access_token=c1f36f510c16df2d261e91a2205fb21d487d853e87118b118d781ceffc3ee799"10 header = {"Content-Type": "application/json","Charset": "UTF-8"}11 tex = "test"12 message ={13 "actionCard":{14 "title": "Tronscan UI自动化用例执行结果",15 "hideAvatar": "0",16 "btnOrientation": "0",17 "text":"Tronscan UI自动化执行失败的用例:\n" + mes,18 "btns": [19 {20 "title": "点击查看测试报告",21 "actionURL": "http://172.16.22.178:8080/job/Tronscan_AutoTest/HTML_20Report/"22 }23 ]24 },25 "msgtype": "actionCard"26 }27 message_json = json.dumps(message)28 info = requests.post(url=webhook,data=message_json,headers=header)29 print(info.text)30def dingSucess():31 webhook = "https://oapi.dingtalk.com/robot/send?access_token=c1f36f510c16df2d261e91a2205fb21d487d853e87118b118d781ceffc3ee799"32 header = {"Content-Type": "application/json","Charset": "UTF-8"}33 tex = "test"34 message ={35 "actionCard":{36 "title": "Tronscan UI自动化用例执行结果",37 "hideAvatar": "0",38 "btnOrientation": "0",39 "text":"Tronscan UI自动化执行通过,无失败用例\n",40 "btns": [41 {42 "title": "点击查看测试报告",43 "actionURL": "http://172.16.22.178:8080/job/Tronscan_AutoTest/HTML_20Report/"44 }45 ]46 },47 "msgtype": "actionCard"48 }49 message_json = json.dumps(message)50 info = requests.post(url=webhook,data=message_json,headers=header)51 print(info.text)52def file_name(file_dir):53 for root,dirs,files in os.walk(file_dir):54 return files55filesname = file_name("/Users/tron/.jenkins/workspace/Tronscan_AutoTest/build/reports/tests/tronscan/classes/")56count=057failClass = []58fail_class = []59for file in filesname:60 dir = "/Users/tron/.jenkins/workspace/Tronscan_AutoTest/build/reports/tests/tronscan/classes/" + file61 print(dir)62 fp = open(dir,"r")63 for s in fp.readlines():64 li=re.findall("infoBox failures", s)65 if len(li)>0:66 failClass.append(file)67 count=count+len(li)68print("search:",count,">>>infoBox failures")69if count > 0:70 fail_class = []71 for failclass in failClass:72 fail_class.append(failclass.split(".")[3])73 print(fail_class)74 ding(fail_class)...

Full Screen

Full Screen

tronscanAPI.py

Source:tronscanAPI.py Github

copy

Full Screen

1import re2import os3import requests4import json5def ding(fail_class):6 mes = ""7 for i in fail_class:8 mes += "- " + i + "\n"9 webhook = "https://oapi.dingtalk.com/robot/send?access_token=c1f36f510c16df2d261e91a2205fb21d487d853e87118b118d781ceffc3ee799"10 header = {"Content-Type": "application/json","Charset": "UTF-8"}11 tex = "test"12 message ={13 "actionCard":{14 "title": "Tronscan API自动化用例执行结果",15 "hideAvatar": "0",16 "btnOrientation": "0",17 "text":"Tronscan API自动化执行失败的用例:\n" + mes,18 "btns": [19 {20 "title": "点击查看测试报告",21 "actionURL": "http://172.16.22.178:8080/job/Tronscan_AutoTest/HTML_20Report/"22 }23 ]24 },25 "msgtype": "actionCard"26 }27 message_json = json.dumps(message)28 info = requests.post(url=webhook,data=message_json,headers=header)29 print(info.text)30def dingSucess():31 webhook = "https://oapi.dingtalk.com/robot/send?access_token=c1f36f510c16df2d261e91a2205fb21d487d853e87118b118d781ceffc3ee799"32 header = {"Content-Type": "application/json","Charset": "UTF-8"}33 tex = "test"34 message ={35 "actionCard":{36 "title": "Tronscan API自动化用例执行结果",37 "hideAvatar": "0",38 "btnOrientation": "0",39 "text":"Tronscan API自动化执行通过,无失败用例\n",40 "btns": [41 {42 "title": "点击查看测试报告",43 "actionURL": "http://172.16.22.178:8080/job/Tronscan_Api/HTML_20Report/"44 }45 ]46 },47 "msgtype": "actionCard"48 }49 message_json = json.dumps(message)50 info = requests.post(url=webhook,data=message_json,headers=header)51 print(info.text)52def file_name(file_dir):53 for root,dirs,files in os.walk(file_dir):54 return files55filesname = file_name("/Users/tron/.jenkins/workspace/Tronscan_Api/build/reports/tests/tronscanAPI/classes/")56count=057failClass = []58fail_class = []59for file in filesname:60 dir = "/Users/tron/.jenkins/workspace/Tronscan_Api/build/reports/tests/tronscanAPI/classes/" + file61 print(dir)62 fp = open(dir,"r")63 for s in fp.readlines():64 li=re.findall("infoBox failures", s)65 if len(li)>0:66 failClass.append(file)67 count=count+len(li)68print("search:",count,">>>infoBox failures")69if count > 0:70 fail_class = []71 for failclass in failClass:72 fail_class.append(failclass.split(".")[3])73 print(fail_class)74 ding(fail_class)...

Full Screen

Full Screen

job.py

Source:job.py Github

copy

Full Screen

1def create_ordered_params(*args):2 return [str(i).lower() for i in args]3def create_id(*args):4 "_".join(create_ordered_params(args)).replace(" ", "")5class Job:6 def __init__(self, seed, topo, routing, algorithm, num_s, num_d, use_min_s,7 use_max_s, use_min_d, use_max_d, traffic_combo, f_scenario, fail_class, nfe, overlap, s_fail, d_fail,8 ignore, num_threads, use_aws):9 self.seed = seed10 self.topo = topo11 self.routing = routing12 self.algorithm = algorithm13 self.num_s = num_s14 self.num_d = num_d15 self.use_min_s = use_min_s16 self.use_max_s = use_max_s17 self.use_min_d = use_min_d18 self.use_max_d = use_max_d19 self.traffic_combo = traffic_combo20 self.f_scenario = f_scenario21 self.fail_class = fail_class22 self.nfe = nfe23 self.overlap = overlap24 self.s_fail = s_fail25 self.d_fail = d_fail26 self.ignore = ignore27 self.num_threads = num_threads28 self.use_aws = use_aws29 self.ordered_params = create_ordered_params(seed, topo, routing, algorithm, num_s, num_d, use_min_s,30 use_max_s, use_min_d, use_max_d, traffic_combo, f_scenario,31 fail_class, nfe, overlap, s_fail, d_fail, ignore, num_threads)32 self.request_id = "_".join(self.ordered_params).replace(" ", "")33def build_request(seed=1, topo="NSFnet", routing="Unicast", algorithm="ILP", num_s=1, num_d=1,34 use_min_s=0, use_max_s=None, use_min_d=0, use_max_d=None, traffic_combo="none", f_scenario="default",35 fail_type="Both", nfe=0, overlap="none", s_fail="prevent", d_fail="prevent", ignore=True,36 num_threads=8, use_aws=True):37 if use_max_s is None:38 use_max_s = num_s39 if use_max_d is None:40 use_max_d = num_d41 return Job(seed, topo, routing, algorithm, num_s, num_d, use_min_s,42 use_max_s, use_min_d, use_max_d, traffic_combo, f_scenario, fail_type, nfe, overlap, s_fail, d_fail,...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful