def is_make_snapshot(self): """Check if the test 'test_name' is a dependency for other planned tests (snapshot is required). If yes return True, if no - False. :rtype: bool """ test_name = get_test_method_name() tests = self.test_program.plan.tests test_cases = [t for t in tests if t.entry.method.__name__ == test_name] if len(test_cases) != 1: logger.warning("Method 'is_make_snapshot' is called from function " "which is not a test case: {0}".format(test_name)) return False test_groups = set(test_cases[0].entry.info.groups) dependent_tests = set() dependent_groups = set() for t in tests: for func in t.entry.info.depends_on: dependent_tests.add(func.__name__) for group in t.entry.info.depends_on_groups: dependent_groups.add(group) if test_name in dependent_tests or \ test_groups & dependent_groups: return True return False
def show_step(self, step, details='', initialize=False): """Show a description of the step taken from docstring :param int/str step: step number to show :param str details: additional info for a step """ test_func_name = get_test_method_name() if initialize or step == 1: self.current_log_step = step else: self.current_log_step += 1 if self.current_log_step != step: error_message = 'The step {} should be {} at {}' error_message = error_message.format( step, self.current_log_step, test_func_name ) logger.error(error_message) test_func = getattr(self.__class__, test_func_name) docstring = test_func.__doc__ docstring = '\n'.join([s.strip() for s in docstring.split('\n')]) steps = {s.split('. ')[0]: s for s in docstring.split('\n') if s and s[0].isdigit()} if details: details_msg = ': {0} '.format(details) else: details_msg = '' if str(step) in steps: logger.info("\n" + " " * 55 + "<<< {0} {1}>>>" .format(steps[str(step)], details_msg)) else: logger.info("\n" + " " * 55 + "<<< {0}. (no step description " "in scenario) {1}>>>".format(str(step), details_msg))
def show_step(self, step, details='', initialize=False): """Show a description of the step taken from docstring :param int/str step: step number to show :param str details: additional info for a step """ test_func_name = get_test_method_name() if initialize: self.current_log_step = step else: self.current_log_step += 1 if self.current_log_step != step: error_message = 'The step {} should be {} at {}' error_message = error_message.format(step, self.current_log_step, test_func_name) logger.error(error_message) test_func = getattr(self.__class__, test_func_name) docstring = test_func.__doc__ docstring = '\n'.join([s.strip() for s in docstring.split('\n')]) steps = { s.split('. ')[0]: s for s in docstring.split('\n') if s and s[0].isdigit() } if details: details_msg = ': {0} '.format(details) else: details_msg = '' if str(step) in steps: logger.info("\n" + " " * 55 + "<<< {0} {1}>>>".format(steps[str(step)], details_msg)) else: logger.info("\n" + " " * 55 + "<<< {0}. (no step description " "in scenario) {1}>>>".format(str(step), details_msg))
def show_step(self, step, details=''): """Show a description of the step taken from docstring :param int/str step: step number to show :param str details: additional info for a step """ test_func_name = get_test_method_name() test_func = getattr(self.__class__, test_func_name) docstring = test_func.__doc__ docstring = '\n'.join([s.strip() for s in docstring.split('\n')]) steps = {s.split('. ')[0]: s for s in docstring.split('\n') if s and s[0].isdigit()} if details: details_msg = ': {0} '.format(details) else: details_msg = '' if str(step) in steps: logger.info("\n" + " " * 55 + "<<< {0} {1}>>>" .format(steps[str(step)], details_msg)) else: logger.info("\n" + " " * 55 + "<<< {0}. (no step description " "in scenario) {1}>>>".format(str(step), details_msg))
def show_step(self, step, details=''): """Show a description of the step taken from docstring :param int/str step: step number to show :param str details: additional info for a step """ test_func_name = get_test_method_name() test_func = getattr(self.__class__, test_func_name) docstring = test_func.__doc__ docstring = '\n'.join([s.strip() for s in docstring.split('\n')]) steps = { s.split('. ')[0]: s for s in docstring.split('\n') if s and s[0].isdigit() } if details: details_msg = ': {0} '.format(details) else: details_msg = '' if str(step) in steps: logger.info("\n" + " " * 55 + "<<< {0} {1}>>>".format(steps[str(step)], details_msg)) else: logger.info("\n" + " " * 55 + "<<< {0}. (no step description " "in scenario) {1}>>>".format(str(step), details_msg))