def tearDown(self): # Get unit test exception py2_exception = sys.exc_info()[1] try: # Python 3.4+ exception_info = self._outcome.errors[-1][1] if len( self._outcome.errors) > 0 else None exception = exception_info[1] if exception_info else None except AttributeError: try: # Python 3.3 exceptions_list = self._outcomeForDoCleanups.failures + self._outcomeForDoCleanups.errors exception = exceptions_list[0][1] if exceptions_list else None except AttributeError: # Python 2.7 exception = py2_exception if not exception: self._test_passed = True self.logger.info("The test '%s' has passed", self.get_subclassmethod_name()) else: self._test_passed = False error_message = get_error_message_from_exception(exception) self.logger.error("The test '%s' has failed: %s", self.get_subclassmethod_name(), error_message)
def modified_test(*args, **kwargs): save_jira_conf() try: test_item(*args, **kwargs) except Exception as e: error_message = get_error_message_from_exception(e) test_comment = "The test '{}' has failed: {}".format(args[0].get_method_name(), error_message) add_jira_status(test_key, 'Fail', test_comment) raise add_jira_status(test_key, 'Pass', None)
def tearDown(self): # Get unit test exception exception_info = self._outcome.errors[-1][1] if len( self._outcome.errors) > 0 else None exception = exception_info[1] if exception_info else None if not exception: self._test_passed = True self.logger.info("The test '%s' has passed", self.get_subclassmethod_name()) else: self._test_passed = False error_message = get_error_message_from_exception(exception) self.logger.error("The test '%s' has failed: %s", self.get_subclassmethod_name(), error_message)
def tearDown(self): # Get unit test exception py2_exception = sys.exc_info()[1] try: # Python 3.4+ exception_info = self._outcome.errors[-1][1] if len(self._outcome.errors) > 0 else None exception = exception_info[1] if exception_info else None except AttributeError: try: # Python 3.3 exceptions_list = self._outcomeForDoCleanups.failures + self._outcomeForDoCleanups.errors exception = exceptions_list[0][1] if exceptions_list else None except AttributeError: # Python 2.7 exception = py2_exception if not exception: self._test_passed = True self.logger.info("The test '{0}' has passed".format(self.get_subclassmethod_name())) else: self._test_passed = False error_message = get_error_message_from_exception(exception) self.logger.error("The test '{0}' has failed: {1}".format(self.get_subclassmethod_name(), error_message))