class RunnableTestCase(BaseTestCase): def __init__(self, tc_data, parent, defaults): BaseTestCase.__init__(self, tc_data.name, parent) self.doc = tc_data.doc.value self.setup = defaults.get_setup(tc_data.setup) self.teardown = defaults.get_teardown(tc_data.teardown) self.tags = defaults.get_tags(tc_data.tags) self.timeout = defaults.get_timeout(tc_data.timeout) template = defaults.get_template(tc_data.template) self.keywords = Keywords(tc_data.steps, template) def run(self, context, suite_errors): self._suite_errors = suite_errors self._start_run(context) if self.run_errors.is_allowed_to_run(): self._run(context) else: self._not_allowed_to_run() self._end_run(context) def _start_run(self, context): self.run_errors = TestRunErrors(self._suite_errors) self.status = 'RUNNING' self.starttime = utils.get_timestamp() self.run_errors.init_err(self._init_test(context)) context.start_test(self) def _init_test(self, context): errors = [] self.doc = context.replace_vars_from_setting('Documentation', self.doc, errors) self.setup.replace_variables(context.get_current_vars(), errors) self.teardown.replace_variables(context.get_current_vars(), errors) self.tags = utils.normalize_tags(context.replace_vars_from_setting('Tags', self.tags, errors)) self.timeout.replace_variables(context.get_current_vars()) if errors: return 'Test case initialization failed:\n%s' % '\n'.join(errors) if not self.name: return 'Test case name is required.' if not self.keywords: return 'Test case contains no keywords' return None def _run(self, context): self.timeout.start() self._run_setup(context) if not self.run_errors.setup_failed(): try: self.keywords.run(context) except ExecutionFailed, err: self.run_errors.kw_err(unicode(err)) self.keyword_failed(err) context.set_test_status_before_teardown(*self._report_status()) self._run_teardown(context) self._report_status_after_teardown()
class RunnableTestCase(BaseTestCase): def __init__(self, tc_data, parent, defaults): BaseTestCase.__init__(self, tc_data.name, parent) self.doc = tc_data.doc.value self.setup = defaults.get_setup(tc_data.setup) self.teardown = defaults.get_teardown(tc_data.teardown) self.tags = defaults.get_tags(tc_data.tags) self.timeout = defaults.get_timeout(tc_data.timeout) template = defaults.get_template(tc_data.template) self.keywords = Keywords(tc_data.steps, template) def run(self, context, suite_errors): self._suite_errors = suite_errors self._start_run(context) if self.run_errors.is_allowed_to_run(): self._run(context) else: self._not_allowed_to_run() self._end_run(context) def _start_run(self, context): self.run_errors = TestRunErrors(self._suite_errors) self.status = 'RUNNING' self.starttime = utils.get_timestamp() self.run_errors.init_err(self._init_test(context)) context.start_test(self) def _init_test(self, context): errors = [] self.doc = context.replace_vars_from_setting('Documentation', self.doc, errors) self.setup.replace_variables(context.get_current_vars(), errors) self.teardown.replace_variables(context.get_current_vars(), errors) self.tags = utils.normalize_tags( context.replace_vars_from_setting('Tags', self.tags, errors)) self.timeout.replace_variables(context.get_current_vars()) if errors: return 'Test case initialization failed:\n%s' % '\n'.join(errors) if not self.name: return 'Test case name is required.' if not self.keywords: return 'Test case contains no keywords' return None def _run(self, context): self.timeout.start() self._run_setup(context) if not self.run_errors.setup_failed(): try: self.keywords.run(context) except ExecutionFailed, err: self.run_errors.kw_err(unicode(err)) self.keyword_failed(err) context.set_test_status_before_teardown(*self._report_status()) self._run_teardown(context) self._report_status_after_teardown()
def _start_run(self, context): self.run_errors = TestRunErrors(self._suite_errors) self.status = 'RUNNING' self.starttime = utils.get_timestamp() self.run_errors.init_err(self._init_test(context)) context.start_test(self)