How to use test_relative_path method in autotest

Best Python code snippet using autotest_python

memory.py

Source:memory.py Github

copy

Full Screen

1# coding=utf-82# 内存测试3# 使用方法:在本目录下执行 "python -m memory_profiler memory.py"4from memory_profiler import profile5import os6import shutil7import path8import sync9# 初始化10@profile(precision=8)11def init_local():12 sync.init_local()13# 初始化14@profile(precision=8)15def init_udisk():16 sync.init_udisk()17# 全量push18@profile(precision=8)19def fully_push(local_path, udisk_path):20 sync.fully_push(local_path, udisk_path)21# 全量pull22@profile(precision=8)23def fully_pull(udisk_path, local_path):24 sync.fully_pull(udisk_path, local_path)25# 本地增量push26@profile(precision=8)27def incrementally_push():28 sync.incrementally_push()29# 远程增量pull30@profile(precision=8)31def incrementally_pull():32 sync.incrementally_pull()33def tmp1():34 test_local_path = path.test_local_path_root + os.path.sep + path.test_relative_path35 test_udisk_path = path.test_udisk_path_root + os.path.sep + path.test_relative_path36 test_remote_path = path.test_remote_path_root + os.path.sep + path.test_relative_path37 if os.path.exists(test_local_path + os.path.sep + ".sync"):38 shutil.rmtree(test_local_path + os.path.sep + ".sync")39 if os.path.exists(test_local_path + os.path.sep + "test"):40 shutil.rmtree(test_local_path + os.path.sep + "test")41 if os.path.exists(test_udisk_path):42 shutil.rmtree(test_udisk_path)43 if os.path.exists(test_remote_path):44 shutil.rmtree(test_remote_path)45 os.mkdir(test_udisk_path)46 os.mkdir(test_remote_path)47 # 1.本地新增测试需要的文件夹、文件48 os.mkdir(test_local_path + os.path.sep + "test")49 os.mkdir(test_local_path + os.path.sep + "test" + os.path.sep + "test2")50 os.mkdir(test_local_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "test3")51 file_temp = file(test_local_path + os.path.sep + "test" + os.path.sep + "update_local_test_1.txt", "w")52 file_temp.write("update_local_test_1.txt")53 file_temp.close()54 file_temp = file(test_local_path + os.path.sep + "test" + os.path.sep + "delete_local_test_1.txt", "w")55 file_temp.write("delete_local_test_1.txt")56 file_temp.close()57 file_temp = file(58 test_local_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "update_local_test_2.txt", "w")59 file_temp.write("update_local_test_2.txt")60 file_temp.close()61 file_temp = file(62 test_local_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "delete_local_test_2.txt", "w")63 file_temp.write("delete_local_test_2.txt")64 file_temp.close()65 file_temp = file(66 test_local_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "test3" + os.path.sep + "update_local_test_3.txt",67 "w")68 file_temp.write("update_local_test_3.txt")69 file_temp.close()70 file_temp = file(71 test_local_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "test3" + os.path.sep + "delete_local_test_3.txt",72 "w")73 file_temp.write("delete_local_test_3.txt")74 file_temp.close()75 path.local_path = test_local_path76 path.udisk_path = test_udisk_path77def tmp2():78 test_local_path = path.test_local_path_root + os.path.sep + path.test_relative_path79 test_udisk_path = path.test_udisk_path_root + os.path.sep + path.test_relative_path80 test_remote_path = path.test_remote_path_root + os.path.sep + path.test_relative_path81 file_temp = file(test_local_path + os.path.sep + "test" + os.path.sep + "add_local_test_1.txt", "w")82 file_temp.write("add_local_test_1.txt")83 file_temp.close()84 file_temp = file(85 test_local_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "add_local_test_2.txt", "w")86 file_temp.write("add_local_test_2.txt")87 file_temp.close()88 file_temp = file(89 test_local_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "test3" + os.path.sep + "add_local_test_3.txt",90 "w")91 file_temp.write("add_local_test_3.txt")92 file_temp.close()93 # 5.本地修改文件94 file_temp = file(test_local_path + os.path.sep + "test" + os.path.sep + "update_local_test_1.txt", "w")95 file_temp.write("update_local_test_1.txt local_update")96 file_temp.close()97 file_temp = file(98 test_local_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "update_local_test_2.txt", "w")99 file_temp.write("update_local_test_2.txt local_update")100 file_temp.close()101 file_temp = file(102 test_local_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "test3" + os.path.sep + "update_local_test_3.txt",103 "w")104 file_temp.write("update_local_test_3.txt local_update")105 file_temp.close()106 # 6.本地删除文件107 os.remove(test_local_path + os.path.sep + "test" + os.path.sep + "delete_local_test_1.txt")108 os.remove(test_local_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "delete_local_test_2.txt")109 os.remove(110 test_local_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "test3" + os.path.sep + "delete_local_test_3.txt")111 # 7.远程新增文件112 file_temp = file(test_remote_path + os.path.sep + "test" + os.path.sep + "add_remote_test_1.txt", "w")113 file_temp.write("add_remote_test_1.txt")114 file_temp.close()115 file_temp = file(116 test_remote_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "add_remote_test_2.txt", "w")117 file_temp.write("add_remote_test_2.txt")118 file_temp.close()119 file_temp = file(120 test_remote_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "test3" + os.path.sep + "add_remote_test_3.txt",121 "w")122 file_temp.write("add_remote_test_3.txt")123 file_temp.close()124 # 8.远程修改文件125 file_temp = file(test_remote_path + os.path.sep + "test" + os.path.sep + "update_local_test_1.txt", "w")126 file_temp.write("update_local_test_1.txt remote_update")127 file_temp.close()128 file_temp = file(129 test_remote_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "update_local_test_2.txt", "w")130 file_temp.write("update_local_test_2.txt remote_update")131 file_temp.close()132 file_temp = file(133 test_remote_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "test3" + os.path.sep + "update_local_test_3.txt",134 "w")135 file_temp.write("update_local_test_3.txt remote_update")136 file_temp.close()137 # 9.远程删除文件138 os.remove(test_remote_path + os.path.sep + "test" + os.path.sep + "delete_local_test_1.txt")139 os.remove(test_remote_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "delete_local_test_2.txt")140 os.remove(141 test_remote_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "test3" + os.path.sep + "delete_local_test_3.txt")142@profile(precision=3)143def test_run_time():144 test_local_path = path.test_local_path_root + os.path.sep + path.test_relative_path145 test_udisk_path = path.test_udisk_path_root + os.path.sep + path.test_relative_path146 test_remote_path = path.test_remote_path_root + os.path.sep + path.test_relative_path147 tmp1()148 # 2.初始化149 sync.init_local()150 sync.init_udisk()151 # 3.1.全量push152 sync.fully_push(path.local_path, path.udisk_path)153 # 3.2.全量pull154 path.local_path = test_remote_path155 sync.fully_pull(path.udisk_path, path.local_path)156 # 4.本地新增文件157 tmp2()158 # 10.本地增量push、远程增量pull159 path.local_path = test_local_path160 path.udisk_path = test_udisk_path161 sync.incrementally_push()162 path.local_path = test_remote_path163 sync.incrementally_pull()164# 使用方法:在本目录下执行 "python -m memory_profiler memory.py"165if __name__ == '__main__':...

Full Screen

Full Screen

cpu_time0.py

Source:cpu_time0.py Github

copy

Full Screen

1# coding=utf-82# 性能测试:测试程序运行时占用的cpu时间3# 使用方法:在本目录下执行 "kernprof -l -v cpu_time0.py"4import os5import shutil6import path7import sync8def tmp1():9 test_local_path = path.test_local_path_root + os.path.sep + path.test_relative_path10 test_udisk_path = path.test_udisk_path_root + os.path.sep + path.test_relative_path11 test_remote_path = path.test_remote_path_root + os.path.sep + path.test_relative_path12 if os.path.exists(test_local_path + os.path.sep + ".sync"):13 shutil.rmtree(test_local_path + os.path.sep + ".sync")14 if os.path.exists(test_local_path + os.path.sep + "test"):15 shutil.rmtree(test_local_path + os.path.sep + "test")16 if os.path.exists(test_udisk_path):17 shutil.rmtree(test_udisk_path)18 if os.path.exists(test_remote_path):19 shutil.rmtree(test_remote_path)20 os.mkdir(test_udisk_path)21 os.mkdir(test_remote_path)22 # 1.本地新增测试需要的文件夹、文件23 os.mkdir(test_local_path + os.path.sep + "test")24 os.mkdir(test_local_path + os.path.sep + "test" + os.path.sep + "test2")25 os.mkdir(test_local_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "test3")26 file_temp = file(test_local_path + os.path.sep + "test" + os.path.sep + "update_local_test_1.txt", "w")27 file_temp.write("update_local_test_1.txt")28 file_temp.close()29 file_temp = file(test_local_path + os.path.sep + "test" + os.path.sep + "delete_local_test_1.txt", "w")30 file_temp.write("delete_local_test_1.txt")31 file_temp.close()32 file_temp = file(33 test_local_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "update_local_test_2.txt", "w")34 file_temp.write("update_local_test_2.txt")35 file_temp.close()36 file_temp = file(37 test_local_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "delete_local_test_2.txt", "w")38 file_temp.write("delete_local_test_2.txt")39 file_temp.close()40 file_temp = file(41 test_local_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "test3" + os.path.sep + "update_local_test_3.txt",42 "w")43 file_temp.write("update_local_test_3.txt")44 file_temp.close()45 file_temp = file(46 test_local_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "test3" + os.path.sep + "delete_local_test_3.txt",47 "w")48 file_temp.write("delete_local_test_3.txt")49 file_temp.close()50 path.local_path = test_local_path51 path.udisk_path = test_udisk_path52def tmp2():53 test_local_path = path.test_local_path_root + os.path.sep + path.test_relative_path54 test_udisk_path = path.test_udisk_path_root + os.path.sep + path.test_relative_path55 test_remote_path = path.test_remote_path_root + os.path.sep + path.test_relative_path56 file_temp = file(test_local_path + os.path.sep + "test" + os.path.sep + "add_local_test_1.txt", "w")57 file_temp.write("add_local_test_1.txt")58 file_temp.close()59 file_temp = file(60 test_local_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "add_local_test_2.txt", "w")61 file_temp.write("add_local_test_2.txt")62 file_temp.close()63 file_temp = file(64 test_local_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "test3" + os.path.sep + "add_local_test_3.txt",65 "w")66 file_temp.write("add_local_test_3.txt")67 file_temp.close()68 # 5.本地修改文件69 file_temp = file(test_local_path + os.path.sep + "test" + os.path.sep + "update_local_test_1.txt", "w")70 file_temp.write("update_local_test_1.txt local_update")71 file_temp.close()72 file_temp = file(73 test_local_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "update_local_test_2.txt", "w")74 file_temp.write("update_local_test_2.txt local_update")75 file_temp.close()76 file_temp = file(77 test_local_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "test3" + os.path.sep + "update_local_test_3.txt",78 "w")79 file_temp.write("update_local_test_3.txt local_update")80 file_temp.close()81 # 6.本地删除文件82 os.remove(test_local_path + os.path.sep + "test" + os.path.sep + "delete_local_test_1.txt")83 os.remove(test_local_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "delete_local_test_2.txt")84 os.remove(85 test_local_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "test3" + os.path.sep + "delete_local_test_3.txt")86 # 7.远程新增文件87 file_temp = file(test_remote_path + os.path.sep + "test" + os.path.sep + "add_remote_test_1.txt", "w")88 file_temp.write("add_remote_test_1.txt")89 file_temp.close()90 file_temp = file(91 test_remote_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "add_remote_test_2.txt", "w")92 file_temp.write("add_remote_test_2.txt")93 file_temp.close()94 file_temp = file(95 test_remote_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "test3" + os.path.sep + "add_remote_test_3.txt",96 "w")97 file_temp.write("add_remote_test_3.txt")98 file_temp.close()99 # 8.远程修改文件100 file_temp = file(test_remote_path + os.path.sep + "test" + os.path.sep + "update_local_test_1.txt", "w")101 file_temp.write("update_local_test_1.txt remote_update")102 file_temp.close()103 file_temp = file(104 test_remote_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "update_local_test_2.txt", "w")105 file_temp.write("update_local_test_2.txt remote_update")106 file_temp.close()107 file_temp = file(108 test_remote_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "test3" + os.path.sep + "update_local_test_3.txt",109 "w")110 file_temp.write("update_local_test_3.txt remote_update")111 file_temp.close()112 # 9.远程删除文件113 os.remove(test_remote_path + os.path.sep + "test" + os.path.sep + "delete_local_test_1.txt")114 os.remove(test_remote_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "delete_local_test_2.txt")115 os.remove(116 test_remote_path + os.path.sep + "test" + os.path.sep + "test2" + os.path.sep + "test3" + os.path.sep + "delete_local_test_3.txt")117@profile118def test_cpu_time():119 test_local_path = path.test_local_path_root + os.path.sep + path.test_relative_path120 test_udisk_path = path.test_udisk_path_root + os.path.sep + path.test_relative_path121 test_remote_path = path.test_remote_path_root + os.path.sep + path.test_relative_path122 tmp1()123 # 2.初始化124 sync.init_local()125 sync.init_udisk()126 # 3.1.全量push127 sync.fully_push(path.local_path, path.udisk_path)128 # 3.2.全量pull129 path.local_path = test_remote_path130 sync.fully_pull(path.udisk_path, path.local_path)131 # 4.本地新增文件132 tmp2()133 # 10.本地增量push、远程增量pull134 path.local_path = test_local_path135 path.udisk_path = test_udisk_path136 sync.incrementally_push()137 path.local_path = test_remote_path138 sync.incrementally_pull()139if __name__ == "__main__":...

Full Screen

Full Screen

test.py

Source:test.py Github

copy

Full Screen

1import os2import numpy as np3import pandas as pd4from multiprocessing import Pool5import glob6import gc7from utils_mod import tf_itr8from methods import *9def conv_pred(el, file):10 t = 1011 idx = np.argsort(el)[::-1]12 id_10 = file[idx[:t]]13 return ' '.join(['{}'.format(i) for i in id_10])14def predict(test_relative_path, submission_path, FOLDER, num=None):15 cate = pd.read_csv('Category.csv', sep=',')['Label_num'].values16 # LR17 # model = LR(3862)18 # shared-bottom/SB19 # model = SB(cate, [16], [2048, 4096])20 # SNR21 # model = SNR_Trans(cate, [16, 16] ,bottom_0_struct=[512,512,512,512,512,512,512,512],bottom_1_struct=[512,512,512,512,512,512,512,512],beta=0.9, zeta=1.1, gamma=-0.5)22 # CNN23 # model = CNN2(3862)24 # FCN25 model = FCN(3862)26 model.build((None, 1152))27 batch = 10240028 label_num = 386229 wfn = sorted(glob.glob('weights/*.h5'))[-1]30 model.load_weights(wfn)31 print('loaded weight file: %s' % wfn)32 file = pd.read_csv('Mapping_out.csv', sep=',')['OldLabel'].values33 cnt = 034 for d in tf_itr('', batch, label_num=label_num, FOLDER=FOLDER, num=num):35 cnt += 136 idx, x1_val, x2_val, _ = d37 val_in = np.concatenate((x1_val, x2_val), axis=1)38 ypd = model.predict(val_in, verbose=1, batch_size=32)39 del x1_val, x2_val40 out = []41 for i in range(len(ypd)):42 out.append(conv_pred(ypd[i], file))43 df = pd.DataFrame.from_dict({'VideoId': idx, 'Label': out})44 if not os.path.exists(submission_path + '/tmp/' + test_relative_path):45 os.mkdir(submission_path + '/tmp/' + test_relative_path)46 df.to_csv(submission_path + '/tmp/' + test_relative_path + '/subm' + str(cnt) + '.csv', header=True,47 index=False,48 columns=['VideoId', 'Label'])49 gc.collect()50 f_subs = glob.glob(os.path.join(submission_path + '/tmp/' + test_relative_path + '/subm*.csv'))51 print(f_subs)52 df = pd.concat((pd.read_csv(f) for f in f_subs))53 df.to_csv(os.path.join(submission_path + '/11.csv'), index=None)54if __name__ == '__main__':55 submission_path = './output'56 #predict('', submission_path, 'train_validation')57 #predict('train200', submission_path, '../train_s')...

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 autotest 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