How to use is_kind_supported_by_runner_command method in avocado

Best Python code snippet using avocado_python Github


Full Screen

...319 "configuration_used", []320 )321 return capabilities322 @staticmethod323 def is_kind_supported_by_runner_command(324 kind, runner_cmd, capabilities=None, env=None325 ):326 """Checks if a runner command that seems a good fit declares support."""327 if capabilities is None:328 capabilities = Runnable.get_capabilities_from_runner_command(329 runner_cmd, env330 )331 return kind in capabilities.get("runnables", [])332 @staticmethod333 def _module_exists(module_name):334 """Returns whether a nrunner "runner" module exists."""335 module_filename = f"{module_name}.py"336 mod_path = os.path.join("plugins", "runners", module_filename)337 return pkg_resources.resource_exists("avocado", mod_path)338 @staticmethod339 def pick_runner_command(kind, runners_registry=None):340 """Selects a runner command based on the runner kind.341 And when finding a suitable runner, keeps found runners in registry.342 This utility function will look at the given kind and try to find343 a matching runner. The matching runner probe results are kept in344 a registry (that is modified by this function) so that further345 executions take advantage of previous probes.346 This is related to the :data:`SpawnMethod.STANDALONE_EXECUTABLE`347 :param kind: runners' kind348 :type kind: str349 :param runners_registry: a registry with previously found (and not350 found) runners keyed by runnable kind351 :type runners_registry: dict352 :returns: command line arguments to execute the runner353 :rtype: list of str or None354 """355 if runners_registry is None:356 runners_registry = RUNNERS_REGISTRY_STANDALONE_EXECUTABLE357 runner_cmd = runners_registry.get(kind)358 if runner_cmd is False:359 return None360 if runner_cmd is not None:361 return runner_cmd362 # When running Avocado Python modules, the interpreter on the new363 # process needs to know where Avocado can be found.364 env = os.environ.copy()365 env["PYTHONPATH"] = ":".join(p for p in sys.path)366 standalone_executable_cmd = [f"avocado-runner-{kind}"]367 if Runnable.is_kind_supported_by_runner_command(368 kind, standalone_executable_cmd369 ):370 runners_registry[kind] = standalone_executable_cmd371 return standalone_executable_cmd372 # attempt to find Python module files that are named after the373 # runner convention within the avocado.plugins.runners namespace dir.374 # Looking for the file only avoids an attempt to load the module375 # and should be a lot faster376 module_name = kind.replace("-", "_")377 if Runnable._module_exists(module_name):378 full_module_name = f"avocado.plugins.runners.{module_name}"379 candidate_cmd = [sys.executable, "-m", full_module_name]380 if Runnable.is_kind_supported_by_runner_command(381 kind, candidate_cmd, env=env382 ):383 runners_registry[kind] = candidate_cmd384 return candidate_cmd385 # look for the runner commands implemented in the base nrunner module386 candidate_cmd = [sys.executable, "-m", "avocado.core.nrunner"]387 if Runnable.is_kind_supported_by_runner_command(kind, candidate_cmd, env=env):388 runners_registry[kind] = candidate_cmd389 return candidate_cmd390 # exhausted probes, let's save the negative on the cache and avoid391 # future similar problems392 runners_registry[kind] = False393 def runner_command(self, runners_registry=None):394 """Selects a runner command based on the runner.395 And when finding a suitable runner, keeps found runners in registry.396 This utility function will look at the given task and try to find397 a matching runner. The matching runner probe results are kept in398 a registry (that is modified by this function) so that further399 executions take advantage of previous probes.400 This is related to the :data:`SpawnMethod.STANDALONE_EXECUTABLE`401 :param runners_registry: a registry with previously found (and not...

Full Screen

Full Screen Github


Full Screen

...364 def test_is_task_kind_supported(self):365 cmd = ['sh', '-c',366 'test $0 = capabilities && '367 'echo -n {\\"runnables\\": [\\"mykind\\"]}']368 self.assertTrue(self.runnable.is_kind_supported_by_runner_command(cmd))369 def test_is_task_kind_supported_other_kind(self):370 cmd = ['sh', '-c',371 'test $0 = capabilities && '372 'echo -n {\\"runnables\\": [\\"otherkind\\"]}']373 self.assertFalse(self.runnable.is_kind_supported_by_runner_command(cmd))374 def test_is_task_kind_supported_no_output(self):375 cmd = ['sh', '-c', 'echo -n ""']376 self.assertFalse(self.runnable.is_kind_supported_by_runner_command(cmd))377class PickRunner(unittest.TestCase):378 def setUp(self):379 self.runnable = nrunner.Runnable('lets-image-a-kind',380 'test_pick_runner_command')381 def test_pick_runner_command(self):382 runner = ['avocado-runner-lets-image-a-kind']383 known = {'lets-image-a-kind': runner}384 self.assertEqual(self.runnable.pick_runner_command(known), runner)385 def test_pick_runner_command_empty(self):386 self.assertFalse(self.runnable.pick_runner_command({}))387if __name__ == '__main__':...

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?