Best Python code snippet using autotest_python
tester.py
Source:tester.py
...182 perfect_out = OUTPUT_DIR + "/" + test + ".out"183 print "\nRunning "+test+" on " + driver.get_name() + " at "+str( datetime.now() );184 # run test185 try:186 timing_result = self.run_timed_test( driver, test, out, {} )187 except:188 pass189 if not os.path.exists( out ):190 print "driver " + driver.get_name() + " has not implemented " + test191 return True192 if not self.check_results( timing_result ):193 self.add_to_stats( False )194 driver.add_to_stats( False )195 print "driver " + driver.get_name() + " failed to run " + test196 return False197 # diff results198 if os.path.exists( perfect_out ):199 if os.path.exists( out ):200 diff_result = self.diff_test( out, perfect_out )201 else:202 diff_result = { "exit_code" : 0 }203 if not self.check_results( diff_result ):204 print "driver " + driver.get_name() + ":" + test + " generated incorrect output"205 # validate206 validation_result = self.run_validation_test( test, {} )207 if not self.check_results( validation_result ):208 print "driver " + driver.get_name() + ":" + test + " failed validation"209 passed = self.check_results( validation_result ) and self.check_results( diff_result )210 self.add_to_stats( passed )211 driver.add_to_stats( passed )212 # report output213 r = Renderer( out, perfect_out, report )214 r.render( test, driver.get_name(), timing_result, diff_result, validation_result )215 return ( passed == 1 )216 def run_timed_test( self, driver, test, output, result ):217 old_path = os.getcwd()218 output = os.path.abspath(output)219 os.chdir(os.path.dirname(driver.get_path()))220 result[ "begin" ] = datetime.now()221 try:222 print "\nAbout to run "+self.test_dir + driver.get_path()+" "+test+" "+ output+"]";223 result[ "exit_code" ] = subprocess.call( [self.test_dir + driver.get_path(), test, output] )224 except:225 result[ "exit_code" ] = -1226 result[ "end" ] = datetime.now()227 os.chdir(old_path)228 return result229 def run_validation_test( self, test, result ):230 validate_script = VALIDATION_DIR + "/" + test...
tradefed_chromelogin.py
Source:tradefed_chromelogin.py
...67 # effect installs autotest in the right place, so we should not hit68 # this slow path repeatedly.69 logging.warning('Autotest not installed, fallback to slow path...')70 try:71 autotest.Autotest(self._host).run_timed_test(72 'cheets_StartAndroid',73 timeout=2 * timeout,74 check_client_result=True,75 **self._cts_helper_kwargs)76 return True77 except:78 # We were unable to start the browser/Android. Maybe we can79 # salvage the DUT by rebooting. This can hide some failures.80 self.reboot()81 if raise_exception:82 raise83 except:84 # We were unable to start the browser/Android. Maybe we can85 # salvage the DUT by rebooting. This can hide some failures....
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!!