How to use test_no_result method in avocado

Best Python code snippet using avocado_python

7_1no_container_test.py

Source:7_1no_container_test.py Github

copy

Full Screen

1import cv22import numpy as np3import math4import random as rdm5import re67#非集装箱号文本测试的样本生成、结果解析89def loadDataSet(filename): #读取文件,txt文档10 # filename=r'.\data\add_no_number_train.txt'11 fr = open(filename,'r')12 dataMat = []13 line=fr.readline().replace('\n','')14 while line:15 a = line.split(' ')16 dataMat.append(a)17 line = fr.readline().replace('\n','')18 out_data=[]19 for i in range(np.shape(dataMat)[0]):20 if len(dataMat[i])==1:21 this_line=[]22 this_line.append(dataMat[i][0])23 else:24 this_line.append(dataMat[i][0])25 this_line.append(dataMat[i][1])26 this_line.append(dataMat[i][2])27 this_line.append(dataMat[i][3])28 out_data.append(this_line)29 return out_data3031def rotation(img,degree):32 height, width = img.shape[:2]33 # 旋转后的尺寸34 heightNew = int(width * fabs(sin(radians(degree))) + height * fabs(cos(radians(degree))))35 widthNew = int(height * fabs(sin(radians(degree))) + width * fabs(cos(radians(degree))))36 #旋转中心37 matRotation = cv2.getRotationMatrix2D((width / 2, height / 2), degree, 1)3839 matRotation[0, 2] += (widthNew - width) / 2 # 重点在这步40 matRotation[1, 2] += (heightNew - height) / 2 # 重点在这步4142 imgRotation = cv2.warpAffine(img, matRotation, (widthNew, heightNew), borderValue=(255, 255, 255))43 return imgRotation444546#非箱号样本生成47add_no_number=loadDataSet(r'.\data\add_no_number_test.txt')48f=open(r'.\data\caffe_test_add_no_container.txt','w')49for i in range(np.shape(add_no_number)[0]):50 image=cv2.imread(r'..\all_frame_test\%s.jpg'%(add_no_number[i][0]))51 try:52 if image == None:53 image = cv2.imread(r'..\all_frame\%s.jpg' % add_no_number[i][0], cv2.IMREAD_COLOR)54 else:55 pass56 except:57 pass5859 min_x = int(add_no_number[i][1])60 min_y = int(add_no_number[i][2])61 max_x = int(add_no_number[i][3])62 max_y = int(add_no_number[i][4])6364 cut = image[min_y:max_y, min_x:max_x]65 height, width = cut.shape[:2]66 if float(height) / float(width) > 1.5: # 改这里67 cut_rotation = rotation(cut, degree=90)68 cut_res = cv2.resize(cut_rotation, (192, 64))69 else:70 cut_res = cv2.resize(cut, (192, 64))71 '''72 cv2.imshow("cut_res", cut_res)73 cv2.waitKey()74 cv2.destroyAllWindows()75 '''76 cv2.imwrite(r'E:\test_cut\OTHER\0\0\%s.jpg'%(i),cut_res)77 f.write('/data/liuxu/container_qan/test_data/OTHER/0/0/%s.jpg 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 38\n'%i)7879f.close()808182####################非箱号结果拼图8384def write_score(s,color=(255,255,255)):85 font=cv2.FONT_HERSHEY_SIMPLEX#使用默认字体86 im=np.zeros((64,100,3),np.uint8)87 img=cv2.putText(im,s,(0,20),font,0.4,color,1)#添加文字,1.2表示字体大小,(0,40)是初始的位置,(255,255,255)表示颜色,2表示粗细88 #imshow(img)frame_score[0,3]89 return img9091#拼图92test_no_result=np.load(r'.\data\frame_score_test_nocontianer_v822.npy')93add_no_number=loadDataSet(r'.\data\add_no_number_test.txt')9495show_image=np.zeros([1,292,3],np.uint8)96for i in range(np.shape(test_no_result)[0]):97 test_no_result[i,2]=round(1/(1+math.exp(-float(test_no_result[i,2])/(math.e**4))),2) #TODO 改sigmoid98 image = cv2.imread(r'..\test_cut\OTHER\0\0\%s.jpg' % (i))99 this_imnage=np.hstack((image,write_score('score: '+str(test_no_result[i,2]))))100 show_image=np.vstack((show_image,this_imnage))101 '''102 cv2.imshow("show_image", show_image)103 cv2.waitKey()104 cv2.destroyAllWindows()105 '''106cv2.imwrite(r'..\test_result_pool4_v822\on_container_v822.jpg',show_image)107108#############################################看非箱号哪些的比序列内帧最大分大109#图片对应的非箱号评分110test_no_result=np.load(r'.\data\frame_score_test_nocontianer_v822.npy')111add_no_number=loadDataSet(r'.\data\add_no_number_test.txt')112test_result_all=np.load(r'.\data\test_result_all_pool4_v822.npy')113114no_score=[]115for i in range(np.shape(add_no_number)[0]):116 no_score.append([add_no_number[i][0],round(1/(1+math.exp(-float(test_no_result[i,2])/(math.e**4))),2)]) #TODO 改sigmoid117118count=0119for i in range(np.shape(no_score)[0]):120 this_group_0=test_result_all[np.where(test_result_all[:,4]==re.findall('^(.*?).mp?4_[0-9]+$',no_score[i][0])[0])]121 this_group=[]122 for k in range(np.shape(this_group_0)[0]):123 if int(re.findall('.*?_([0-9]+)$',this_group_0[k,0])[0])<=int(re.findall('.*?_([0-9]+)$',no_score[i][0])[0]):124 this_group.append(this_group_0[k].tolist())125 this_group=np.array(this_group)126 if len(this_group)>0:127 if min([float(k) for k in this_group[:,9]])<no_score[i][1]:128 count+=1129 print(this_group)130131132max([float(k) for k in test_result_all[:,9]])133134###############135# 非箱号评分分布136def plot_percentile(data,bins_num,per):137 hist, bins = np.histogram(data, bins=bins_num,)138 x=np.percentile(data,per)139 for i in range(np.shape(bins)[0]-1):140 if bins[i]<=x and bins[i+1]>=x:141 index=i142 y=hist[index]143 plt.plot([x,x,],[0,y],'k--',linewidth=1.5,c=sns.xkcd_rgb['nice blue'])144 plt.text(x+0.01,0.2,str(round(x,2)),color=sns.xkcd_rgb['nice blue'])145 plt.text(x-(bins[1]-bins[0]),y+0.4,str(per)+'%',color=sns.xkcd_rgb['nice blue'])146147test_no_result=np.load(r'.\data\frame_score_test_nocontainer.npy')148for i in range(np.shape(test_no_result)[0]):149 test_no_result[i, 2] = round(1 / (1 + math.exp(-float(test_no_result[i, 2]) / (math.e ** 2))), 2)150151no_container_score=[float(score) for score in test_no_result[:,2]]152sns.distplot(no_container_score, kde=False, bins=20, rug=False)153plot_percentile(no_container_score,20,50)154plot_percentile(no_container_score,20,5)155plot_percentile(no_container_score,20,95)156157###########################158test_no_result=np.load(r'.\data\frame_score_test_nocontianer_v822.npy')159for i in range(np.shape(test_no_result)[0]):160 test_no_result[i, 2] = round(1 / (1 + math.exp(-float(test_no_result[i, 2]) / (math.e ** 4))), 2)161162threthold=0.5163count=0164for i in test_no_result[:,2]:165 if float(i) >=threthold:166 count+=1 ...

Full Screen

Full Screen

test_parametryzation_main.py

Source:test_parametryzation_main.py Github

copy

Full Screen

...10 def test_negative(self):11 assert add(-19, -21) == -4012 assert add(2, -4) == -21314 def test_no_result(self):15 with pytest.raises(TypeError):16 add(0.5, 't')171819class TestSubtractionFunction:20 def test_positive(self):21 assert subtract(17, 8) == 922 assert subtract(20, -4) == 242324 def test_negative(self):25 assert subtract(-23, -21) == -226 assert subtract(-120, -100) == -202728 def test_no_result(self):29 with pytest.raises(TypeError):30 subtract(-7.1, 'ba')313233class TestMultiplicationFunction:34 def test_positive(self):35 assert multiply(-7, -60) == 42036 assert multiply(23, 3) == 693738 def test_negative(self):39 assert multiply(2137, -1) == -213740 assert multiply(2, -44) == -884142 def test_no_result(self):43 with pytest.raises(TypeError):44 multiply('a', 't')454647class TestDivisionFunction:48 def test_positive(self):49 assert divide(5, 5) == 150 assert divide(-1000, -25) == 405152 def test_negative(self):53 assert divide(24, -6) == -454 assert divide(-64, 4) == -165556 def test_no_result(self):57 with pytest.raises(TypeError): ...

Full Screen

Full Screen

test_search_non_existing_course.py

Source:test_search_non_existing_course.py Github

copy

Full Screen

...5from Pages import search6import conftest7import pytest8@pytest.mark.parametrize("config_name", ['python'])9def test_no_result(driver, config_name):10 conftest.logger("-------test_search_non_existing_course_starts--------")11 helpers.go_to_page(driver, sign_up.data['url'])12 sign_in.login_user(driver)13 helpers.find_and_send_keys(driver, search.search_area, config_name)14 helpers.find_and_send_keys(driver, search.search_area, Keys.ENTER)15 no_result_message = helpers.find(driver, search.no_result_txt)16 assert no_result_message, f"Expected {no_result_message.text} but failed"17 conftest.logger(f"Success! Message {no_result_message.text} is displayed")18 conftest.logger("-------test_search_non_existing_course_finished--------")19if __name__ == '__main__':...

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