Best Python code snippet using Airtest
test_aircv.py
Source: test_aircv.py
...26 def tearDownClass(cls):27 pass28 def test_find_template(self):29 """Template matching."""30 result = TemplateMatching(self.template_sch, self.template_src, threshold=self.THRESHOLD, rgb=self.RGB).find_best_result()31 self.assertIsInstance(result, dict)32 def test_find_all_template(self):33 """Template matching."""34 result = TemplateMatching(self.template_sch, self.template_src, threshold=self.THRESHOLD, rgb=self.RGB).find_all_results()35 self.assertIsInstance(result, list)36 def test_find_kaze(self):37 """KAZE matching."""38 # è¾æ
¢,ç¨å¾®ç¨³å®ä¸ç¹.39 result = KAZEMatching(self.keypoint_sch, self.keypoint_src, threshold=self.THRESHOLD, rgb=self.RGB).find_best_result()40 self.assertIsInstance(result, dict)41 def test_find_brisk(self):42 """BRISK matching."""43 # å¿«,ææä¸è¬,ä¸å¤ªç¨³å®44 result = BRISKMatching(self.keypoint_sch, self.keypoint_src, threshold=self.THRESHOLD, rgb=self.RGB).find_best_result()45 self.assertIsInstance(result, dict)46 def test_find_akaze(self):47 """AKAZE matching."""48 # è¾å¿«,ææè¾å·®,å¾ä¸ç¨³å®49 result = AKAZEMatching(self.keypoint_sch, self.keypoint_src, threshold=self.THRESHOLD, rgb=self.RGB).find_best_result()50 self.assertIsInstance(result, dict)51 def test_find_orb(self):52 """ORB matching."""53 # å¾å¿«,ææåå¾54 result = ORBMatching(self.keypoint_sch, self.keypoint_src, threshold=self.THRESHOLD, rgb=self.RGB).find_best_result()55 self.assertIsInstance(result, dict)56 def test_contrib_find_sift(self):57 """SIFT matching (----need OpenCV contrib module----)."""58 # æ
¢,æ稳å®59 result = SIFTMatching(self.keypoint_sch, self.keypoint_src, threshold=self.THRESHOLD, rgb=self.RGB).find_best_result()60 self.assertIsInstance(result, dict)61 def test_contrib_find_surf(self):62 """SURF matching (----need OpenCV contrib module----)."""63 # å¿«,ææä¸é64 result = SURFMatching(self.keypoint_sch, self.keypoint_src, threshold=self.THRESHOLD, rgb=self.RGB).find_best_result()65 self.assertIsInstance(result, dict)66 def test_contrib_find_brief(self):67 """BRIEF matching (----need OpenCV contrib module----)."""68 # è¯å«ç¹å¾ç¹å°,åªéå强ç¹å¾å¾åçå¹é
69 result = BRIEFMatching(self.keypoint_sch, self.keypoint_src, threshold=self.THRESHOLD, rgb=self.RGB).find_best_result()70 self.assertIsInstance(result, dict)71 def test_contrib_func_find_sift(self):72 """Test find_sift function in sift.py."""73 result = find_sift(self.keypoint_src, self.keypoint_sch, threshold=self.THRESHOLD, rgb=self.RGB)74 self.assertIsInstance(result, dict)75 def test_func_find_template(self):76 """Test find_template function in template.py."""77 result = find_template(self.template_src, self.template_sch, threshold=0.9, rgb=self.RGB)78 self.assertIsInstance(result, dict)79 def test_func_find_all_template(self):80 """Test find_all_template function in template.py."""81 result = find_all_template(self.template_src, self.template_sch, threshold=0.9, rgb=self.RGB)82 self.assertIsInstance(result, list)83if __name__ == '__main__':...
common_filter_results_methods.py
Source: common_filter_results_methods.py
...27 if metric!='nan':return img_dir28 29 print(f'#### no image found : {img_dir}')30 return None31def find_best_result(img_dir, metric_name='SSIM', metric_type= 'score'): #metric_type= loss/ score32 img_list = sorted(glob.glob(f"{img_dir}/*.jpg"),key= sort_name_by_epoch, reverse=True)33 min_loss=100034 final_img_dir= None35 36 metric_list=[]37 for img_dir in img_list:38 metric_dict = get_metric(img_dir)39 metric = metric_dict[metric_name]40 if metric!='nan':metric_list.append(metric)41 42 if len(metric_list)==0:43 print(f'#### no img_dir with exceptable metric is found : {img_dir}')44 return None45 min_metric= min(metric_list)46 max_metric= max(metric_list)47 48 for img_dir in img_list:49 metric_dict = get_metric(img_dir)50 metric = metric_dict[metric_name]51 52 img= plt.imread(img_dir)53 is_results_okay= 1 #img[100, 300].sum()< 76554 55 if is_results_okay and metric!='nan':56 #loss= float(loss)57 if metric_type== 'loss':58 if metric<min_metric+0.005:59 return img_dir60 elif metric_type== 'score':61 if metric>max_metric-0.005:62 return img_dir63 64 65 print(f'#### no image found : {img_dir}')66 return None67def get_img_list(img_dir = 'figs/mnistv6', mode='L1Loss', loss_threshold=0.05):68 exp_list = sorted(glob.glob(f'{img_dir}/*@*'))69 70 img_dirs=[]71 for idx in range(len(exp_list)):72 #if idx>102:break73 exp_dir = exp_list[idx]74 75 if mode=='last_converged_correct':img_dir = find_last_converged_correct_result(exp_dir, loss_threshold)76 elif mode=='last_converged_MSE':img_dir = find_last_converged_result(exp_dir, metric_name='MSE', metric_type= 'loss')77 elif mode=='L1Loss':img_dir = find_best_result(exp_dir, metric_name='L1Loss', metric_type= 'loss')78 elif mode=='MSE':img_dir = find_best_result(exp_dir, metric_name='MSE', metric_type= 'loss')79 elif mode=='SSIM':img_dir = find_best_result(exp_dir, metric_name='SSIM', metric_type= 'score')80 elif mode=='SSIM5':img_dir = find_best_result(exp_dir, metric_name='SSIM5', metric_type= 'score')81 elif mode=='SSIM11':img_dir = find_best_result(exp_dir, metric_name='SSIM11', metric_type= 'score')82 83 if idx%100==0:84 print(f'{idx+1}/{len(exp_list)} : {img_dir}')85 86 # exceptions87 #if idx==343:img_dir = find_last_converged_result(exp_dir, 0.130)88 ##89 90 if img_dir==None:91 continue92 93 94 img_dirs.append(img_dir)95 print(f'len img dirs : {len(img_dirs)}')...
Check out the latest blogs from LambdaTest on this topic:
Unit testing is typically software testing within the developer domain. As the QA role expands in DevOps, QAOps, DesignOps, or within an Agile team, QA testers often find themselves creating unit tests. QA testers may create unit tests within the code using a specified unit testing tool, or independently using a variety of methods.
People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.
Agile project management is a great alternative to traditional methods, to address the customer’s needs and the delivery of business value from the beginning of the project. This blog describes the main benefits of Agile for both the customer and the business.
The purpose of developing test cases is to ensure the application functions as expected for the customer. Test cases provide basic application documentation for every function, feature, and integrated connection. Test case development often detects defects in the design or missing requirements early in the development process. Additionally, well-written test cases provide internal documentation for all application processing. Test case development is an important part of determining software quality and keeping defects away from customers.
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
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!!