Best Python code snippet using hypothesis
utils.py
Source:utils.py
...183 schedule_thread.set()184 schedule_thread = None185# </editor-fold>186# <editor-fold desc="Functions for payeer merchant">187def adjust_float(a):188 a = str(a)189 dot_idx = a.find('.')190 if dot_idx == -1:191 a += ".00"192 elif len(a) - dot_idx - 1 < 2:193 a += "0"194 return a195def get_desc_sign(order_id, amount):196 amount = adjust_float(amount)197 desc = binascii.b2a_base64(project_variables.PAYEER_PAY_DESC.encode('utf8'))[:-1].decode()198 string_to_hash = ":".join(199 map(str, [project_variables.PAYEER_MERCHANT_ID, order_id, amount, project_variables.PAYEER_CURRENCY, desc,200 project_variables.PAYEER_SECRET_KEY]))201 return desc, sha256(string_to_hash.encode()).hexdigest().upper()202def check_payment(ip_address, post_data):203 if ip_address in project_variables.PAYEER_TRUSTED_IPS and all(key in post_data for key in post_data_fields):204 parameters = [post_data[post_data_fields[cur_key]][0] for cur_key in range(len(post_data_fields) - 1)]205 if 'm_params' in post_data:206 parameters.append(post_data['m_params'][0])207 parameters.append(project_variables.PAYEER_SECRET_KEY)208 result_hash = sha256(":".join(parameters).encode()).hexdigest().upper()209 if post_data['m_sign'][0] == result_hash:210 if post_data['m_status'][0] == 'success':...
adjust_float.py
Source:adjust_float.py
1"""2Copyright 2016 Korea University & EMCS Labs (Author: Hyungwon Yang)3Apache 2.04*** Introduction ***5This script adjust floating precision in final_ali.txt6*** USAGE ***7Ex. python adjust_float.py $data_file $save_file8"""9import sys10if len(sys.argv) != 3:11 print("Input arguments are incorrectly provided. Two arguments should be assigned.")12 print("1. Data file.")13 print("2. Save file.")14 print("*** USAGE ***")15 print("Ex. python adjust_float.py $data_file $save_file")16 raise ValueError('RETURN')17data_file = sys.argv[1]18save_file = sys.argv[2]19# Import data file.20with open(data_file,'r') as data:21 ali = data.readlines()22# Adjust floating points.23with open(save_file,'w') as save:24 for line in ali:25 tmp_line = line.split('\t')26 start = round(float(line.split('\t')[-2]),2)27 end = round(float(line.split('\t')[-1]),2)28 tmp_line[-2] = str(start)29 tmp_line[-1] = str(end)30 new_line = '\t'.join(tmp_line)...
c.py
Source:c.py
1import math2a, b = map(int, input().split())3na = [a / 0.08, (a+1) / 0.08]4nb = [b / 0.1, (b+1) / 0.1 ]5def adjust_float(l):6 mn, mx = l7 return [8 math.ceil(mn),9 math.floor(mx) if mx % 1 != 0 else int(mx - 1),10 ]11na = adjust_float(na)12nb = adjust_float(nb)13if nb[1] < na[0] or na[1] < nb[0]:14 print(-1)15elif na[0] <= nb[0] and nb[0] <= na[1]:16 print(int(nb[0]))17elif nb[0] <= na[0] and na[0] <= nb[1]:...
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!!