How to use add_case method in Kiwi

Best Python code snippet using Kiwi_python

gen-yaml.py

Source:gen-yaml.py Github

copy

Full Screen

...10random.seed(2020)11MAKE_DATA = len(sys.argv) >= 2 and sys.argv[1] == 'makedata'12CASE = 113manual_cases = set()14def add_case(name, cmd):15 print(' - %s: %s' % (name, cmd))16 if os.path.isfile(cmd) and os.path.splitext(cmd)[1] == '.in':17 manual_cases.add(cmd)18 if MAKE_DATA:19 global CASE20 dst = os.path.join('..', 'data', 'secret', '%02d-%s.in' % (CASE, name))21 CASE += 122 if cmd in manual_cases:23 shutil.copyfile(cmd, dst)24 sys.stderr.write('Copying %s to %s\n' % (cmd, dst))25 else:26 cmd = shlex.split(cmd)27 cmd[0] = './' + cmd[0]28 sys.stderr.write('Running %s > %s\n' % (cmd, dst))29 with open(dst, 'w') as f:30 subprocess.run(cmd, stdout=f, check=True)31print('''## AUTO-GENERATED BY gen-yaml.py, DO NOT EDIT32solution: /submissions/accepted/per_nlogn.cc33data:34 sample:35 type: directory36 solution:37 data:38 '1':39 '2':40 '3':41 '4':42 secret:43 type: directory44 data:''')45 46add_case('small_manual_across', 'manual/across.in')47add_case('small_manual_split', 'manual/split.in')48add_case('small_manual', 'manual/small.in')49add_case('small_manual' , 'manual/misc1.in')50add_case('small_manual' , 'manual/misc2.in')51add_case('single_stack', 'uniform.py --maxn 1')52add_case('single_stack_empty', 'uniform.py --maxn 1 --maxh 0')53for i in range(5):54 add_case('small_uniform_low' , 'uniform.py --maxn 10 --maxh 10 --seed %d' % i)55for i in range(3):56 add_case('big_uniform_low' ,'uniform.py --maxh 10 --seed %d' % (i + 10))57add_case('big_uniform_medium', 'uniform.py --maxh %d --seed 15' % (MAX_N//4))58add_case('big_uniform_high' , 'uniform.py --seed 16')59for i in range(2):60 add_case('big_few_peaks', 'fewpeaks.py %d %d %d %d %d --seed %d' %61 (MAX_N//2, MAX_N-MAX_N//2-10, 9, 1, 0, i+20))62for i in range(2):63 add_case('big_few_peaks', 'fewpeaks.py %d %d %d %d %d --seed %d' %64 (MAX_N//2, MAX_N-MAX_N//2-2, 0, 0, 2, i+30))65for i in range(2):66 add_case('big_few_peaks', 'fewpeaks.py %d %d %d %d %d --seed %d' %67 (95*MAX_N//100, MAX_N-95*MAX_N//100-3, 0, 3, 0, i+40))68add_case('max_all_zeros', 'uniform.py --minn %d --maxh 0' % MAX_N)69add_case('max_all_ones', 'uniform.py --minn %d --minh 1 --maxh 1' % MAX_N)70add_case('max_uniform_balanced', 'uniform.py --minn %d --maxh 2' % MAX_N)71add_case('max_answer', 'uniform.py --minn %d --minh %d' % (MAX_N, MAX_H))72add_case('anti_quadratic', 'antiquadratic1.py %d %d 1' % (MAX_N, MAX_N//2))73add_case('anti_quadratic', 'antiquadratic1.py %d %d 2' % (MAX_N, MAX_N//2))74add_case('anti_quadratic', 'antiquadratic2.py %d %d -1' % (MAX_N, MAX_N//2))75add_case('anti_quadratic', 'antiquadratic2.py %d %d -1' % (MAX_N, 2*MAX_N//3))76add_case('anti_quadratic', 'antiquadratic2.py %d %d 1' % (MAX_N, MAX_N//2))77add_case('anti_quadratic', 'antiquadratic2.py %d %d 1' % (MAX_N, MAX_N//3))78add_case('big_dense', 'manual/big.in')79add_case('big_sparse', 'manual/big_sparse1.in')80add_case('bug_ragnar', 'fewpeaks.py 4 4 0 0 0 --seed 1497354887')81add_case('big_geometric_balanced', 'geometric.py --n %d --seed 51' % MAX_N)82add_case('big_geometric_fewerblocks', 'geometric.py --n %d --p 0.6 --seed 52' % MAX_N)83add_case('big_geometric_moreblocks', 'geometric.py --n %d --p 0.4 --seed 53' % MAX_N)84for i in range(4):85 blocks = MAX_N + int(random.normalvariate(0, 100))86 add_case('big_%d_blocks_into_%d_stacks' % (blocks, MAX_N), 'ballsintobins.py --n %d --blocks %d --seed %d' %87 (MAX_N, blocks, 100+i))88print('# Before editing this file, read comment on first line of file.')89for (p, _, files) in os.walk('manual'):90 for f in files:91 path = os.path.join(p, f)92 if path not in manual_cases:...

Full Screen

Full Screen

generate_value_tests.py

Source:generate_value_tests.py Github

copy

Full Screen

...17from arbitrum import value, marshall, ast18if __name__ == "__main__":19 cases = []20 random.seed(143235)21 def add_case(val, name, is_codepoint=None):22 if is_codepoint is None:23 is_codepoint = False24 data = io.BytesIO()25 marshall.marshall_value(val, data)26 proof_data = io.BytesIO()27 marshall.marshall_value(val, proof_data)28 cases.append(29 {30 "value": data.getvalue().hex(),31 "proof_value": proof_data.getvalue().hex(),32 "hash": value.value_hash(val).hex(),33 "name": name,34 "is_codepoint": is_codepoint,35 }36 )37 simple_tup = value.Tuple([5, 2, 6])38 nest1_tup = value.Tuple([5, simple_tup, 6, simple_tup])39 add_case(10, "int")40 next_hash = bytearray(random.getrandbits(8) for _ in range(32))41 basic = value.AVMCodePoint(0, ast.BasicOp(8), next_hash)42 immediate = value.AVMCodePoint(43 0, ast.ImmediateOp(ast.BasicOp(8), simple_tup), next_hash44 )45 add_case(basic, "simple codepoint", True)46 add_case(immediate, "immediate codepoint", True)47 for i in range(9):48 add_case(value.Tuple([0] * i), "tup" + str(i))49 add_case(simple_tup, "simple_tup")50 add_case(nest1_tup, "nested_tup")51 add_case(52 value.Tuple([nest1_tup, simple_tup, nest1_tup, simple_tup]), "double_nested_tup"53 )54 with open("test_cases.json", "w") as f:55 json.dump(cases, f, indent=4)56 locations = [57 "../arb-bridge-eth/test/test_cases.json",58 "../arb-avm-cpp/tests/test_cases.json",59 "../arb-util/value/test_cases.json",60 "../arb-provider-ethers/test/test_cases.json",61 ]62 for loc in locations:63 with open(loc, "w") as f:...

Full Screen

Full Screen

generate.py

Source:generate.py Github

copy

Full Screen

...3MAX_M = 254MAX_N = 255MAX_MN = 1006case_no = 07def add_case(m, n, case_name = ''):8 if m >= 2 and n >= 2 and m <= MAX_M and n <= MAX_N:9 global case_no10 case_no += 111 file_name = '%02d' % case_no12 if case_name:13 file_name = file_name + '-' + case_name14 file_name += '.in'15 with open(file_name, "wt") as f:16 f.write('%d %d\n' % (n, m))17def main():18 random.seed(0)19 add_case(2, 2, "small")20 add_case(2, 3, "small")21 add_case(3, 2, "small")22 add_case(3, 3, "small")23 add_case(4, 3, "small")24 add_case(4, 4, "small")25 add_case(5, 4, "small")26 add_case(5, 5, "small")27 m = MAX_M - 128 n = int(math.floor(MAX_MN / m))29 add_case(m, n, "large")30 add_case(m, n - 1, "large")31 add_case(m - 1, n, "large")32 add_case(m - 1, n - 1, "large")33 n = MAX_N - 134 m = int(math.floor(MAX_MN / n))35 add_case(m, n, "large")36 add_case(m, n - 1, "large")37 add_case(m - 1, n, "large")38 add_case(m - 1, n - 1, "large")39 n = int(math.floor(math.sqrt(MAX_MN)))40 m = int(math.floor(MAX_MN / n))41 add_case(m, n, "square")42 cnt = 043 while cnt < 10:44 m = random.randint(2, MAX_M)45 n = random.randint(2, MAX_N)46 if m * n > MAX_MN:47 continue48 add_case(m, n, "random")49 cnt += 150if __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 Kiwi 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