How to use load_all_client_tests method in autotest

Best Python code snippet using autotest_python Github


Full Screen

...72 logging.exception("%s: %s", test_name, e)73 finally:74 sys.path.pop(0) # pop up testbindir75 return client_test76def load_all_client_tests(options):77 """78 Load and instantiate all client tests.79 This function is inspired from runtest() on client/common_lib/ @param options: an object passed in from command line OptionParser.81 See all options defined on client/bin/autotest.82 @return a tuple containing the list of all instantiated tests and83 a list of tests that failed to instantiate.84 """85 local_namespace = locals().copy()86 global_namespace = globals().copy()87 all_tests = []88 broken_tests = []89 for test_base_dir in ['tests', 'site_tests']:90 testdir = os.path.join(os.environ['AUTODIR'], test_base_dir)91 for test_name in sorted(os.listdir(testdir)):92 client_test = init_test(options, os.path.join(testdir, test_name))93 if client_test:94 all_tests.append(client_test)95 else:96 broken_tests.append(test_name)97 return all_tests, broken_tests98def setup_test(client_test):99 """100 Direct invoke test.setup() method.101 @returns A boolean to represent success or not.102 """103 # TODO: check if its already build. .version? hash?104 test_name = client_test.__class__.__name__105 cwd = os.getcwd()106 good_setup = False107 try:108 try:109 outputdir = os.path.join(client_test.job.resultdir, test_name)110 try:111 os.makedirs(outputdir)112 os.chdir(outputdir)113 except OSError:114 pass115'setup %s.' % test_name)116 client_test.setup()117 # Touch .version file under src to prevent further setup on client118 # host. See client/common_lib/ update_version()119 if os.path.exists(client_test.srcdir):120 versionfile = os.path.join(client_test.srcdir, '.version')121 pickle.dump(client_test.version, open(versionfile, 'w'))122 good_setup = True123 except Exception, err:124 logging.error(err)125 raise error.AutoservError('Failed to build client test %s on '126 'server.' % test_name)127 finally:128 # back to original working dir129 os.chdir(cwd)130 return good_setup131def setup_tests(options):132 """133 Load and instantiate all client tests.134 This function is inspired from runtest() on client/common_lib/ @param options: an object passed in from command line OptionParser.136 See all options defined on client/bin/autotest.137 """138 assert options.client_test_setup, 'Specify prebuild client tests on the ' \139 'command line.'140 requested_tests = options.client_test_setup.split(',')141 candidates, broken_tests = load_all_client_tests(options)142 failed_tests = []143 if 'all' in requested_tests:144 need_to_setup = candidates145 failed_tests += broken_tests146 else:147 need_to_setup = []148 for candidate in candidates:149 if candidate.__class__.__name__ in requested_tests:150 need_to_setup.append(candidate)151 for broken_test in broken_tests:152 if broken_test in requested_tests:153 failed_tests.append(broken_test)154 if need_to_setup:155 cwd = os.getcwd()...

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:


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?