How to use resolutions_to_runnables method in avocado

Best Python code snippet using avocado_python Github


Full Screen

...582 self.config["prefix"] = ""583 self.config["subcommand"] = "run"584 self.loader.config = self.config585 resolutions = [self.loader.resolve(reference)]586 runnables = resolutions_to_runnables(resolutions, self.config)587 test_suite = TestSuite('suite',588 config=self.config,589 tests=runnables,590 resolutions=resolutions)591 DummyStateCheck.present_states = []592 DummyTestRunning.asserted_tests = [593 {"shortname": "^internal.stateless.noop.vm1", "vms": "^vm1$"},594 {"shortname": "^original.unattended_install.cdrom.extra_cdrom_ks.default_install.aio_threads.vm1", "vms": "^vm1$", "set_state_images": "^install$"},595 {"shortname": "^internal.automated.customize.vm1", "vms": "^vm1$", "get_state_images": "^install$", "set_state_images": "^customize$"},596 {"shortname": "^internal.automated.on_customize.vm1", "vms": "^vm1$", "get_state_images": "^customize$", "set_state_vms": "^on_customize$"},597 {"shortname": "^normal.nongui.quicktest.tutorial1.vm1", "vms": "^vm1$", "get_state_vms": "^on_customize$"},598 ]599 async def serve_forever(): pass600 server_instance = mock_status_server.return_value...

Full Screen

Full Screen Github


Full Screen

...31 RESOLUTION_NOT_STARTED = object()32 TESTS_NOT_FOUND = object()33 TESTS_FOUND = object()34 UNKNOWN = object()35def resolutions_to_runnables(resolutions, config):36 """37 Transforms resolver resolutions into runnables suitable for a suite38 A resolver resolution39 (:class:`avocado.core.resolver.ReferenceResolution`) contains40 information about the resolution process (if it was successful41 or not) and in case of successful resolutions a list of42 resolutions. It's expected that the resolution contain one43 or more :class:`avocado.core.nrunner.Runnable`.44 This function sets the runnable specific configuration for each45 runnable. It also performs tag based filtering on the runnables46 for possibly excluding some of the Runnables.47 :param resolutions: possible multiple resolutions for multiple48 references49 :type resolutions: list of :class:`avocado.core.resolver.ReferenceResolution`50 :param config: job configuration51 :type config: dict52 :returns: the resolutions converted to runnables53 :rtype: list of :class:`avocado.core.nrunner.Runnable`54 """55 result = []56 filter_by_tags = config.get("filter.by_tags.tags")57 include_empty = config.get("filter.by_tags.include_empty")58 include_empty_key = config.get("filter.by_tags.include_empty_key")59 for resolution in resolutions:60 if resolution.result != ReferenceResolutionResult.SUCCESS:61 continue62 for runnable in resolution.resolutions:63 if filter_by_tags:64 if not filter_test_tags_runnable(65 runnable, filter_by_tags, include_empty, include_empty_key66 ):67 continue68 result.append(runnable)69 return result70class TestSuite:71 def __init__(72 self,73 name,74 config=None,75 tests=None,76 job_config=None,77 resolutions=None,78 enabled=True,79 ):80 = name81 self.tests = tests82 self.resolutions = resolutions83 self.enabled = enabled84 # Create a complete config dict with all registered options + custom85 # config86 self.config = settings.as_dict()87 if job_config:88 self.config.update(job_config)89 if config:90 self.config.update(config)91 self._variants = None92 self._references = None93 self._runner = None94 self._test_parameters = None95 self._check_both_parameters_and_variants()96 if self.config.get("run.dry_run.enabled"):97 self._convert_to_dry_run()98 if self.size == 0:99 return100 def _has_both_parameters_and_variants(self):101 if not self.test_parameters:102 return False103 for variant in self.variants.itertests():104 var = variant.get("variant")105 if not is_empty_variant(var):106 return True107 return False108 def _check_both_parameters_and_variants(self):109 if self._has_both_parameters_and_variants():110 err_msg = (111 "Specifying test parameters (with config entry "112 '"run.test_parameters" or command line "-p") along with '113 'any varianter plugin (run "avocado plugins" for a list)'114 " is not yet supported. Please use one or the other."115 )116 raise TestSuiteError(err_msg)117 def __len__(self):118 """This is a convenient method to run `len()` over this object.119 With this you can run: len(a_suite) and will return the same as120 `len(a_suite.tests)`.121 """122 return self.size123 def _convert_to_dry_run(self):124 if self.config.get("run.test_runner") == "nrunner":125 for runnable in self.tests:126 runnable.kind = "dry-run"127 @classmethod128 def _from_config_with_resolver(cls, config, name=None):129 ignore_missing = config.get("run.ignore_missing_references")130 references = config.get("resolver.references")131 try:132 hint = None133 hint_filepath = ".avocado.hint"134 if os.path.exists(hint_filepath):135 hint = HintParser(hint_filepath)136 resolutions = resolve(137 references, hint=hint, ignore_missing=ignore_missing, config=config138 )139 except JobTestSuiteReferenceResolutionError as details:140 raise TestSuiteError(details)141 runnables = resolutions_to_runnables(resolutions, config)142 if name is None:143 name = str(uuid4())144 return cls(name=name, config=config, tests=runnables, resolutions=resolutions)145 def _get_stats_from_nrunner(self):146 stats = {}147 for test in self.tests:148 self._increment_dict_key_counter(stats, test.kind)149 return stats150 def _get_tags_stats_from_nrunner(self):151 stats = {}152 for runnable in self.tests:153 if runnable is None:154 continue155 tags = runnable.tags or {}...

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 avocado 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?