Best Python code snippet using pandera_python
validator.py
Source:validator.py
...21 @staticmethod22 def validate_number(value):23 number_str = str(value)24 if not number_str.isnumeric():25 return AllErrors().collect_error('number')26 return int(number_str)27 @staticmethod28 def validate_phone_number(phone_number):29 phone_number_length = len(phone_number)30 code = '+380'31 is_valid = False32 if code in phone_number:33 is_valid = True34 if phone_number_length == 11:35 is_valid = True36 if is_valid:37 return phone_number38 else:39 return AllErrors().collect_error('phone')40 @staticmethod41 def validate_email(email):42 if not re.fullmatch(r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b', email):43 return AllErrors().collect_error('email')44 return email45 @staticmethod46 def validate_position(position):47 position_list = ['BE Developer', 'FE Developer', 'DevOps']48 if position in position_list:49 return position50 else:51 return AllErrors().collect_error('position')52 @staticmethod53 def validate_name(name):54 if any(char.isdigit() for char in name):55 return AllErrors().collect_error('name')56 return name57 @staticmethod58 def validate_availability(availability):59 all_hrs = 4060 if int(availability) > all_hrs:61 return AllErrors().collect_error('avail')62 else:63 return availability64 @staticmethod65 def is_exist(list_of_elements, id):66 for element in list_of_elements:67 if element.ID == int(id):68 return AllErrors().collect_error('id')...
extractErrorsMutants.py
Source:extractErrorsMutants.py
1import cPickle2from os.path import exists3import os, subprocess, sys4error=float(0.0000000)5cum_error=float(0.0000000)6LUDecomposition='LUDecomposition_'7work=str(sys.argv[1])8Magnitude='.out.Magnitude.'9Mantissa='10'10collect='collect_error'11i='i'12it='6'13last='.tmp'14error_value='error_value'15collect_error=[]16for x in xrange(0, 52):17 #print x 18 Mantissa=str(x)19 for y in xrange(1, 11):20 #print y21 it=str(y)22 inputfile= LUDecomposition + work + Magnitude + Mantissa +i + it + last 23 print inputfile24 if exists(inputfile):25 with open(inputfile) as f:26 mutant_file_content = f.readlines()27 for line in mutant_file_content:28 line_elem= line.split(':')29 ##print line_elem 30 if(len(line_elem)< 2):31 pass32 else:33 if(line_elem[0].strip()=='Error value') or(line_elem[0].strip()=='Error Value') :34 35 error=float(line_elem[1].rstrip())36 ##print error 37 cum_error=float(cum_error)+error38 ##print cum_error 39 40 else: 41 pass42 43 ##print inputfile44 collect_error.append(cum_error)45 ##print collect_error46 cum_error=float(0.0000000)47 if (x==51) and (y==10):48 out_path=os.getcwd()49 #print out_path50 else:51 pass52##i#print collect_error53##print 'I reach'54out_path=os.getcwd()55print out_path56out_path=out_path+error_value57outfile = open(out_path,'wb')58outfile.writelines(str(collect_error))59outfile.close()60collect_error=[]61cum_error=float(0.0000000)62 #os.chdir(prev)63 ...
extractErrorsMutants1.py
Source:extractErrorsMutants1.py
1import cPickle2from os.path import exists3import os, subprocess, sys4error=float(0.0000000)5cum_error=float(0.0000000)6LUDecomposition='LUDecomposition_'7work=str(sys.argv[1])8Magnitude='.out.Magnitude.'9Mantissa='10'10collect='collect_error'11i='i'12it='6'13last='.tmp'14error_value='error_value'15collect_error=[]16for x in xrange(0, 52):17 #print x 18 Mantissa=str(x)19 for y in xrange(1, 11):20 #print y21 it=str(y)22 inputfile= LUDecomposition + work + Magnitude + Mantissa +i + it + last 23 print inputfile24 if exists(inputfile):25 with open(inputfile) as f:26 mutant_file_content = f.readlines()27 for line in mutant_file_content:28 line_elem= line.split(':')29 ##print line_elem 30 if(len(line_elem)< 2):31 pass32 else:33 if(line_elem[0].strip()=='Error value') or(line_elem[0].strip()=='Error Value') :34 35 error=float(line_elem[1].rstrip())36 ##print error 37 cum_error=float(cum_error)+error38 ##print cum_error 39 40 else: 41 pass42 43 ##print inputfile44 collect_error.append(cum_error)45 ##print collect_error46 cum_error=float(0.0000000)47 if (x==51) and (y==10):48 out_path=os.getcwd()49 #print out_path50 else:51 pass52##i#print collect_error53##print 'I reach'54out_path=os.getcwd()55print out_path56out_path=out_path+error_value57outfile = open(out_path,'wb')58outfile.writelines(str(collect_error))59outfile.close()60collect_error=[]61cum_error=float(0.0000000)62 #os.chdir(prev)63 ...
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!!