How to use get_capabilities_from_runner_command method in avocado

Best Python code snippet using avocado_python

runnable.py

Source:runnable.py Github

copy

Full Screen

...288 """289 with open(recipe_path, "w", encoding="utf-8") as recipe_file:290 recipe_file.write(self.get_json())291 @staticmethod292 def get_capabilities_from_runner_command(runner_command, env=None):293 """Returns the capabilities of a given runner from a command.294 In case of failures, an empty capabilities dictionary is returned.295 When the capabilities are obtained, it also updates the296 :data:`STANDALONE_EXECUTABLE_CONFIG_USED` info.297 """298 cmd = runner_command + ["capabilities"]299 try:300 process = subprocess.Popen(301 cmd,302 stdin=subprocess.DEVNULL,303 stdout=subprocess.PIPE,304 stderr=subprocess.DEVNULL,305 env=env,306 )307 except (FileNotFoundError, PermissionError):308 return {}309 out, _ = process.communicate()310 try:311 capabilities = json.loads(out.decode())312 except json.decoder.JSONDecodeError:313 capabilities = {}314 # lists are not hashable, and here it'd make more sense to have315 # a command as it'd be seen in a command line anyway316 cmd = " ".join(runner_command)317 if cmd not in STANDALONE_EXECUTABLE_CONFIG_USED:318 STANDALONE_EXECUTABLE_CONFIG_USED[cmd] = capabilities.get(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 find...

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:

YouTube

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?

Helpful

NotHelpful