How to use guess_recipe_from_runner method in avocado

Best Python code snippet using avocado_python

test_nrunner_interface.py

Source:test_nrunner_interface.py Github

copy

Full Screen

...12 def get_runner(self):13 default_runner = f"{sys.executable} -m avocado.core.nrunner"14 return self.params.get("runner", default=default_runner)15 @staticmethod16 def guess_recipe_from_runner(runner, recipe_type):17 recipe_file_name = f"recipe_{recipe_type}"18 match = re.match(r"^avocado-runner-(.*)$", runner)19 if match:20 underlined = match.group(1).replace("-", "_")21 recipe_file_name += f"_{underlined}.json"22 else:23 recipe_file_name += ".json"24 return recipe_file_name25 @fail_on(process.CmdError)26 def test_help(self):27 """28 Makes sure a runner can be called with --help and that the29 basic required commands are present in the help message30 """31 cmd = f"{self.get_runner()} --help"32 result = process.run(cmd)33 self.assertIn(34 b"capabilities", result.stdout, "Mention to capabilities command not found"35 )36 @skipUnless(JSONSCHEMA_AVAILABLE, "jsonschema module not available")37 @fail_on(process.CmdError)38 def test_schema_capabilities(self):39 cmd = f"{self.get_runner()} capabilities"40 result = process.run(cmd)41 capabilities = json.loads(result.stdout_text)42 schema_path = self.get_data("capabilities.schema.json")43 if not schema_path:44 self.error('Schema file not found for "capabilities"')45 with open(schema_path, "r", encoding="utf-8") as schema:46 try:47 jsonschema.validate(capabilities, json.load(schema))48 except jsonschema.exceptions.ValidationError as details:49 self.fail(details)50 def test_runnable_run_no_args(self):51 cmd = f"{self.get_runner()} runnable-run"52 result = process.run(cmd, ignore_status=True)53 expected = int(self.params.get("runnable-run-no-args-exit-code", default=2))54 self.assertEqual(result.exit_status, expected)55 def test_runnable_run_uri_only(self):56 cmd = f"{self.get_runner()} runnable-run -u some_uri"57 result = process.run(cmd, ignore_status=True)58 expected = int(self.params.get("runnable-run-uri-only-exit-code", default=2))59 self.assertEqual(result.exit_status, expected)60 def test_runnable_run_recipe_no_args(self):61 """62 Makes sure the recipe argument is required63 """64 cmd = f"{self.get_runner()} runnable-run-recipe"65 result = process.run(cmd, ignore_status=True)66 self.assertEqual(result.exit_status, 2)67 def test_runnable_run_recipe_specific_kind(self):68 runner = self.get_runner()69 recipe_file = self.guess_recipe_from_runner(runner, "runnable")70 recipe = self.get_data(recipe_file)71 if not recipe:72 self.cancel("Recipe file not found for this kind of runner")73 cmd = f"{runner} runnable-run-recipe {recipe}"74 result = process.run(cmd, ignore_status=True)75 self.assertEqual(result.exit_status, 0)76 def test_task_run_no_args(self):77 cmd = f"{self.get_runner()} task-run"78 result = process.run(cmd, ignore_status=True)79 self.assertEqual(result.exit_status, 2)80 def test_task_run_identifier_only(self):81 cmd = f"{self.get_runner()} task-run -i some_identifier"82 result = process.run(cmd, ignore_status=True)83 expected = int(self.params.get("task-run-id-only-exit-code", default=2))84 self.assertEqual(result.exit_status, expected)85 def test_task_run_recipe_no_args(self):86 """87 Makes sure the recipe argument is required88 """89 cmd = f"{self.get_runner()} task-run-recipe"90 result = process.run(cmd, ignore_status=True)91 self.assertEqual(result.exit_status, 2)92 def test_task_run_recipe_specific_kind(self):93 runner = self.get_runner()94 recipe_file = self.guess_recipe_from_runner(runner, "task")95 recipe = self.get_data(recipe_file)96 if not recipe:97 self.cancel("Recipe file not found for this kind of runner")98 cmd = f"{runner} task-run-recipe {recipe}"99 result = process.run(cmd, ignore_status=True)...

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