Best Python code snippet using lisa_python
testsuite.py
Source:testsuite.py
...682 )683 class_prefix = f"{key}."684 for test_case in _all_cases.values():685 if test_case.full_name.startswith(class_prefix):686 _add_case_to_suite(metadata, test_case)687 log = get_logger("init", "test")688 log.info(689 f"registered test suite '{key}' "690 f"with test cases: '{', '.join([case.name for case in metadata.cases])}'"691 )692def _add_case_metadata(metadata: TestCaseMetadata) -> None:693 qualname = metadata.qualname694 if _all_cases.get(qualname) is None:695 _all_cases[qualname] = metadata696 else:697 raise LisaException(698 f"found duplicate test class name: {qualname}. "699 "Check there is no duplicate test class name, "700 "and not import by extension twice."701 )702 # this should be None in current observation.703 # the methods are loaded prior to test class704 # in case logic is changed, so keep this logic705 # to make two collection consistent.706 class_name = qualname.split(".")[0]707 test_suite = _all_suites.get(class_name)708 if test_suite:709 log = get_logger("init", "test")710 log.debug(f"add case '{metadata.name}' to suite '{test_suite.name}'")711 _add_case_to_suite(test_suite, metadata)712def _add_case_to_suite(713 test_suite: TestSuiteMetadata, test_case: TestCaseMetadata714) -> None:715 test_case.suite = test_suite716 test_case.full_name = f"{test_suite.name}.{test_case.name}"717 test_suite.cases.append(test_case)...
tempest_test.py
Source:tempest_test.py
...79 return tempest_test_suite80 def _find_integrate_tests(self, parser):81 # Get test_suite82 tempest_test_suite = self._find_tempest_tests()83 def _add_case_to_suite(case, params):84 params['id'] = case85 params['name'] = case86 test_parameters = {'name': case,87 'ct_params': params}88 avocado_test_suite.append((TempestTest,89 test_parameters))90 avocado_test_suite = []91 for params in (_ for _ in parser.get_dicts()):92 if 'integrate' not in params.get('ct_type'):93 continue94 tempest_run_type = params.get('tempest_run_type')95 if tempest_run_type in 'full':96 _add_case_to_suite('tempest', params)97 return avocado_test_suite98 if tempest_run_type in 'smoke':99 _add_case_to_suite('tempest_smoke', params)100 return avocado_test_suite101 for case in tempest_test_suite:102 case_name_prefix = '.'.join(case.split('.')[:1])103 if tempest_run_type in 'module':104 case = '.'.join(case.split('.')[:-3])105 if tempest_run_type in 'suite':106 case = '.'.join(case.split('.')[:-2])107 if tempest_run_type in 'class':108 case = '.'.join(case.split('.')[:-1])109 # if case_name_prefix in params.get('test_types').split(' '):110 if case_name_prefix in 'tempest':111 if params.get('tests') not in 'all':112 # User specified cases list113 specified_cases = params.get('tests').split(' ')114 if case in specified_cases:115 _add_case_to_suite(case, params)116 else:117 _add_case_to_suite(case, params)118 return avocado_test_suite119 def discover(self, url, which_tests=loader.DEFAULT):120 try:121 cartesian_parser = self._get_parser()122 except Exception, details:123 raise EnvironmentError(details)124 all_tests = []125 all_tests.extend(self._find_integrate_tests(cartesian_parser))126 if url is not None:127 avocado_suite = []128 for klass, test_params in all_tests:129 if url in test_params.get('name'):130 avocado_suite.append((klass, test_params))131 return avocado_suite...
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!!