Best Python code snippet using yandex-tank
main.py
Source:main.py
...66 else: #after_test67 pass686970def is_test_finished():71 for i in xrange(len(CORES1)):72 if not CORES1[i].test_status:73 return 074 return 1757677def is_task_finished():78 for i in xrange(len(CORES1)):79 if CORES1[i].status:80 return 081 return 1828384def core_for_test():85 for i in xrange(len(CORES1)):86 if not CORES1[i].test_status:87 if not CORES1[i].type:88 CORES1[i].test = TEST_DIC[i]89 return CORES1[i]90 for i in xrange(len(CORES1)):91 if not CORES1[i].test_status:92 CORES1[i].test = TEST_DIC[i]93 return CORES1[i]94 return None959697def test_dispatch():98 global TESTING99 global TEST_TIME100 if TESTING.test.status == 1: #pre_test101 if TESTING.type: #unbreakable102 if not TESTING.status:103 TESTING.test.pre_test -= 1104 if TESTING.test.pre_test <= 0:105 TESTING.test.status = 2106 else: #breakable107 TESTING.test.pre_test -= 1108 if TESTING.test.pre_test <= 0:109 TESTING.test.status = 2110111 elif TESTING.test.status == 2: #under test112 TEST_TIME += 1113 if TESTING.type: #unbreakable114 TESTING.test.under_test -= 1115 if TESTING.test.under_test <= 0 and TESTING.status == None:116 TESTING.test.status = 3117 else: #breakable118 TESTING.test.under_test -= 1119 if TESTING.test.under_test <= 0:120 TESTING.test.status = 3121 if TESTING.status:122 TESTING.status.status = 2 #task stalled123124 else: #after test125 TESTING.test.after_test -= 1126 if TESTING.test.after_test <= 0:127 TESTING.test_status = 1128 if TESTING.status:129 TESTING.status.status = 1130 TESTING.test = None131 TESTING = None132133134def run_graph():135 global CYCLE136 global TEST_FINISHED137 global TASK_FINISHED138 global TESTING139 global TEST_TIME140 global TEST_FINISHED_TIME141 global TASK_FINISHED_TIME142 CYCLE = 0143 TEST_FINISHED = 0144 TASK_FINISHED = 0145 TEST_TIME = 0146 test_recording = 1147 task_recording = 1148 while not (TASK_FINISHED and TEST_FINISHED):149 CYCLE += 1150151 # build_log()152 if not TESTING and not TEST_FINISHED:153 TESTING = core_for_test()154 test_dispatch()155 task_dispatch()156 else:157 if not TEST_FINISHED:158 test_dispatch()159 task_dispatch()160161 TEST_FINISHED = is_test_finished()162 TASK_FINISHED = is_task_finished()163 if TEST_FINISHED and test_recording:164 TEST_FINISHED_TIME = CYCLE165 test_recording = 0166 if TASK_FINISHED and task_recording:167 TASK_FINISHED_TIME = CYCLE168 task_recording = 0169 # build_log()170 # print task_finished_time171 # print test_finished_time172173174def run_graph_2():175 global CYCLE
...
performance_test.py
Source:performance_test.py
...22 csv_details_url = root.xpath(".//detailCSV/child::text()")[0]23 if vars.verbose:24 print("waiting for XML to appear at", xml_url)25 print("waiting for CSV to appear at", csv_url)26 def is_test_finished():27 resp = requests.get(xml_url)28 root = lxml.etree.fromstring(resp.content)29 status = root.xpath(".//statusCode/child::text()")[0]30 if "100" in status or "101" in status:31 return False32 return True33 time.sleep(5)34 max_attempts = 1035 for i in range(max_attempts):36 if is_test_finished():37 break38 time.sleep(5)39 print(".", end=" ", flush=True)40 time.sleep(5)41 print(".", end=" ", flush=True)42 else:43 raise Exception("timed out")44 resp = requests.get(xml_url) #add params={"pagespeed": "1"} to get scorecard results45 root = lxml.etree.fromstring(resp.content)46 fv = first_view = root.find(".//data/run/firstView/results")47 rv = repeat_view = root.find(".//data/run/repeatView/results")48 fv_load_time = fv.find(".//loadTime")49 rv_load_time = rv.find(".//loadTime")50 print()...
lesson.py
Source:lesson.py
1from typing import Union2from PyYandexLMS.models.base.lesson import BaseLesson3from PyYandexLMS.models.base.main import BaseModel4class Lesson(BaseLesson):5 description: str6 duration: Union[int, None]7 score: int8 is_test_started: Union[bool, None]9 is_test_finished: Union[bool, None]10class NotificationLesson(BaseModel):11 id: int12 type: str13 title: str14 is_accepted: bool...
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!!