How to use _catch_test_status method in avocado

Best Python code snippet using avocado_python

test.py

Source:test.py Github

copy

Full Screen

...587 os.environ["AVOCADO_TEST_WORKDIR"] = self.workdir588 os.environ["AVOCADO_TEST_LOGDIR"] = self.logdir589 os.environ["AVOCADO_TEST_LOGFILE"] = self.logfile590 os.environ["AVOCADO_TEST_OUTPUTDIR"] = self.outputdir591 def _catch_test_status(self, method):592 """Wrapper around test methods for catching and logging failures."""593 try:594 method()595 if self.__log_warn_used and self.__status not in STATUSES_NOT_OK:596 raise exceptions.TestWarn(597 "Test passed but there were warnings "598 "during execution. Check the log for "599 "details."600 )601 except exceptions.TestBaseException as detail:602 self.__status = detail.status603 self.__fail_class = detail.__class__.__name__604 self.__fail_reason = astring.to_text(detail)605 self.__traceback = stacktrace.prepare_exc_info(sys.exc_info())606 except AssertionError as detail:607 self.__status = "FAIL"608 self.__fail_class = detail.__class__.__name__609 self.__fail_reason = astring.to_text(detail)610 self.__traceback = stacktrace.prepare_exc_info(sys.exc_info())611 except Exception as detail: # pylint: disable=W0703612 self.__status = "ERROR"613 tb_info = stacktrace.tb_info(sys.exc_info())614 self.__traceback = stacktrace.prepare_exc_info(sys.exc_info())615 try:616 self.__fail_class = astring.to_text(detail.__class__.__name__)617 self.__fail_reason = astring.to_text(detail)618 except TypeError:619 self.__fail_class = "Exception"620 self.__fail_reason = (621 "Unable to get exception, check the traceback for details."622 )623 for e_line in tb_info:624 self.log.error(e_line)625 def run_avocado(self):626 """627 Wraps the run method, for execution inside the avocado runner.628 :result: Unused param, compatibility with :class:`unittest.TestCase`.629 """630 self._setup_environment_variables()631 self._catch_test_status(self._run_test)632 self._catch_test_status(self._tearDown)633 whiteboard_file = os.path.join(self.logdir, "whiteboard")634 genio.write_file(whiteboard_file, self.whiteboard)635 self.__phase = "FINISHED"636 self._tag_end()637 self._report()638 self.log.info("")639 def _report(self):640 """641 Report result to the logging system.642 """643 if self.fail_reason is not None:644 self.log.error(645 "%s %s -> %s: %s",646 self.status,...

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