Esempio n. 1
0
 def visit_test(self, test):
     if test.name in self._executed_tests:
         self._output.warn("Multiple test cases with name '%s' executed in "
                           "test suite '%s'." %
                           (test.name, self._suite.longname))
     self._executed_tests[test.name] = True
     result = self._suite.tests.create(name=test.name,
                                       doc=self._resolve_setting(test.doc),
                                       tags=test.tags,
                                       starttime=get_timestamp(),
                                       timeout=self._get_timeout(test))
     status = TestStatus(self._suite_status, result.critical)
     if not status.failures and not test.name:
         status.test_failed('Test case name cannot be empty.')
     if not status.failures and not test.keywords.normal:
         status.test_failed('Test case contains no keywords.')
     try:
         result.tags = self._context.variables.replace_list(result.tags)
     except DataError as err:
         status.test_failed(
             'Replacing variables from test tags failed: %s' % unicode(err))
     self._context.start_test(result)
     self._output.start_test(ModelCombiner(result, test))
     if status.exit:
         self._add_exit_combine()
         result.tags.add('robot-exit')
     self._run_setup(test.keywords.setup, status, result)
     try:
         if not status.failures:
             runner = KeywordRunner(self._context, bool(test.template))
             runner.run_keywords(test.keywords.normal)
         else:
             status.test_failed(status.message)
     except PassExecution as exception:
         err = exception.earlier_failures
         if err:
             status.test_failed(err)
         else:
             result.message = exception.message
     except ExecutionFailed as err:
         status.test_failed(err)
     result.status = status.status
     result.message = status.message or result.message
     if status.teardown_allowed:
         with self._context.test_teardown(result):
             failure = self._run_teardown(test.keywords.teardown, status,
                                          result)
             if failure and result.critical:
                 status.critical_failure_occurred()
     if not status.failures and result.timeout and result.timeout.timed_out(
     ):
         status.test_failed(result.timeout.get_message())
         result.message = status.message
     result.status = status.status
     result.endtime = get_timestamp()
     self._output.end_test(ModelCombiner(result, test))
     self._context.end_test(result)
Esempio n. 2
0
File: runner.py Progetto: Garjy/RIDE
 def visit_test(self, test):
     if test.name in self._executed_tests:
         self._output.warn("Multiple test cases with name '%s' executed in "
                           "test suite '%s'." % (test.name, self._suite.longname))
     self._executed_tests[test.name] = True
     result = self._suite.tests.create(name=test.name,
                                       doc=self._resolve_setting(test.doc),
                                       tags=test.tags,
                                       starttime=get_timestamp(),
                                       timeout=self._get_timeout(test))
     status = TestStatus(self._suite_status, result.critical)
     if not status.failures and not test.name:
         status.test_failed('Test case name cannot be empty.')
     if not status.failures and not test.keywords.normal:
         status.test_failed('Test case contains no keywords.')
     try:
         result.tags = self._context.variables.replace_list(result.tags)
     except DataError as err:
         status.test_failed('Replacing variables from test tags failed: %s'
                            % unicode(err))
     self._context.start_test(result)
     self._output.start_test(ModelCombiner(result, test))
     if status.exit:
         self._add_exit_combine()
         result.tags.add('robot-exit')
     self._run_setup(test.keywords.setup, status, result)
     try:
         if not status.failures:
             runner = KeywordRunner(self._context, bool(test.template))
             runner.run_keywords(test.keywords.normal)
         else:
             status.test_failed(status.message)
     except PassExecution as exception:
         err = exception.earlier_failures
         if err:
             status.test_failed(err)
         else:
             result.message = exception.message
     except ExecutionFailed as err:
         status.test_failed(err)
     result.status = status.status
     result.message = status.message or result.message
     if status.teardown_allowed:
         with self._context.test_teardown(result):
             failure = self._run_teardown(test.keywords.teardown, status,
                                          result)
             if failure and result.critical:
                 status.critical_failure_occurred()
     if not status.failures and result.timeout and result.timeout.timed_out():
         status.test_failed(result.timeout.get_message())
         result.message = status.message
     result.status = status.status
     result.endtime = get_timestamp()
     self._output.end_test(ModelCombiner(result, test))
     self._context.end_test(result)
Esempio n. 3
0
 def _write(self, text, separator=False, level='INFO', timestamp=None):
     if separator and self._separator_written_last:
         return
     if not separator:
         text = '%s - %s - %s' % (timestamp or get_timestamp(), level, text)
     self._outfile.write(text.rstrip() + '\n')
     self._outfile.flush()
     self._separator_written_last = separator
Esempio n. 4
0
 def __exit__(self, exc_type, exc_val, exc_tb):
     if exc_val is None:
         self._result.status = self._pass_status
     elif isinstance(exc_val, ExecutionFailed):
         self._result.status = exc_val.status
         if self._result.type == self._result.TEARDOWN_TYPE:
             self._result.message = unicode(exc_val)
     self._result.endtime = get_timestamp()
     self._context.end_keyword(self._result)
 def _write(self, text, separator=False, level='INFO', timestamp=None):
     if separator and self._separator_written_last:
         return
     if not separator:
         text = '%s - %s - %s' % (timestamp or utils.get_timestamp(),
                                  level, text)
     self._outfile.write(text.encode('UTF-8').rstrip() + '\n')
     self._outfile.flush()
     self._separator_written_last = separator
Esempio n. 6
0
 def _get_writer(self, path, generator):
     if not path:
         return NullMarkupWriter()
     try:
         writer = XmlWriter(path, encoding='UTF-8', write_empty=False)
     except EnvironmentError as err:
         raise DataError("Opening output file '%s' failed: %s" %
                         (path, err.strerror))
     writer.start('robot', {'generator': get_full_version(generator),
                            'generated': get_timestamp()})
     return writer
Esempio n. 7
0
 def write(self, libdoc, outfile):
     writer = XmlWriter(outfile)
     writer.start('keywordspec', {'name': libdoc.name, 'type': libdoc.type,
                                  'format': libdoc.doc_format,
                                  'generated': get_timestamp(millissep=None)})
     writer.element('version', libdoc.version)
     writer.element('scope', libdoc.scope)
     writer.element('namedargs', 'yes' if libdoc.named_args else 'no')
     writer.element('doc', libdoc.doc)
     self._write_keywords('init', libdoc.inits, writer)
     self._write_keywords('kw', libdoc.keywords, writer)
     writer.end('keywordspec')
     writer.close()
 def write(self, libdoc, outfile):
     writer = XmlWriter(outfile, encoding='UTF-8')
     writer.start('keywordspec', {'name': libdoc.name, 'type': libdoc.type,
                                  'format': libdoc.doc_format,
                                  'generated': get_timestamp(millissep=None)})
     writer.element('version', libdoc.version)
     writer.element('scope', libdoc.scope)
     writer.element('namedargs', 'yes' if libdoc.named_args else 'no')
     writer.element('doc', libdoc.doc)
     self._write_keywords('init', libdoc.inits, writer)
     self._write_keywords('kw', libdoc.keywords, writer)
     writer.end('keywordspec')
     writer.close()
Esempio n. 9
0
 def convert(self, libdoc):
     return {
         'name': libdoc.name,
         'doc': self._doc_formatter.html(libdoc.doc, intro=True),
         'version': libdoc.version,
         'named_args': libdoc.named_args,
         'scope': libdoc.scope,
         'generated': get_timestamp(daysep='-', millissep=None),
         'inits': self._get_keywords(libdoc.inits),
         'keywords': self._get_keywords(libdoc.keywords),
         'all_tags': tuple(libdoc.all_tags),
         'contains_tags': bool(libdoc.all_tags)
     }
Esempio n. 10
0
 def convert(self, libdoc):
     return {
         'name': libdoc.name,
         'doc': self._doc_formatter.html(libdoc.doc, intro=True),
         'version': libdoc.version,
         'named_args': libdoc.named_args,
         'scope': libdoc.scope,
         'generated': get_timestamp(daysep='-', millissep=None),
         'inits': self._get_keywords(libdoc.inits),
         'keywords': self._get_keywords(libdoc.keywords),
         'all_tags': tuple(libdoc.all_tags),
         'contains_tags': bool(libdoc.all_tags)
     }
Esempio n. 11
0
 def _get_writer(self, path, generator):
     if not path:
         return NullMarkupWriter()
     try:
         writer = XmlWriter(path, encoding='UTF-8', write_empty=False)
     except EnvironmentError as err:
         raise DataError("Opening output file '%s' failed: %s" %
                         (path, err.strerror))
     writer.start('robot', {
         'generator': get_full_version(generator),
         'generated': get_timestamp()
     })
     return writer
Esempio n. 12
0
File: runner.py Progetto: Garjy/RIDE
 def end_suite(self, suite):
     self._suite.message = self._suite_status.message
     self._context.report_suite_status(self._suite.status,
                                       self._suite.full_message)
     with self._context.suite_teardown():
         failure = self._run_teardown(suite.keywords.teardown, self._suite_status)
         if failure:
             self._suite.suite_teardown_failed(unicode(failure))
             if self._suite.statistics.critical.failed:
                 self._suite_status.critical_failure_occurred()
     self._suite.endtime = get_timestamp()
     self._suite.message = self._suite_status.message
     self._context.end_suite(self._suite)
     self._suite = self._suite.parent
     self._suite_status = self._suite_status.parent
Esempio n. 13
0
 def __exit__(self, exc_type, exc_val, exc_tb):
     context = self._context
     result = self._result
     failure = self._get_failure(exc_type, exc_val, exc_tb, context)
     if failure is None:
         result.status = self._pass_status
     else:
         result.status = failure.status
         if result.type == result.TEARDOWN_TYPE:
             result.message = failure.message
     if context.test:
         context.test.passed = self._test_passed and result.passed
     result.endtime = get_timestamp()
     context.end_keyword(result)
     if failure is not exc_val:
         raise failure
Esempio n. 14
0
 def __exit__(self, exc_type, exc_val, exc_tb):
     context = self._context
     result = self._result
     failure = self._get_failure(exc_type, exc_val, exc_tb, context)
     if failure is None:
         result.status = self._pass_status
     else:
         result.status = failure.status
         if result.type == result.TEARDOWN_TYPE:
             result.message = failure.message
     if context.test:
         context.test.passed = self._test_passed and result.passed
     result.endtime = get_timestamp()
     context.end_keyword(result)
     if failure is not exc_val:
         raise failure
Esempio n. 15
0
 def end_suite(self, suite):
     self._suite.message = self._suite_status.message
     self._context.report_suite_status(self._suite.status,
                                       self._suite.full_message)
     with self._context.suite_teardown():
         failure = self._run_teardown(suite.keywords.teardown,
                                      self._suite_status)
         if failure:
             self._suite.suite_teardown_failed(unicode(failure))
             if self._suite.statistics.critical.failed:
                 self._suite_status.critical_failure_occurred()
     self._suite.endtime = get_timestamp()
     self._suite.message = self._suite_status.message
     self._context.end_suite(self._suite)
     self._suite = self._suite.parent
     self._suite_status = self._suite_status.parent
Esempio n. 16
0
 def end_suite(self, suite):
     self._suite.message = self._suite_status.message
     self._context.report_suite_status(self._suite.status,
                                       self._suite.full_message)
     with self._context.suite_teardown():
         failure = self._run_teardown(suite.keywords.teardown, self._suite_status)
         if failure:
             self._suite.suite_teardown_failed(unic(failure))
             if self._suite.statistics.critical.failed:
                 self._suite_status.critical_failure_occurred()
     self._suite.endtime = get_timestamp()
     self._suite.message = self._suite_status.message
     self._context.end_suite(ModelCombiner(suite, self._suite))
     self._suite = self._suite.parent
     self._suite_status = self._suite_status.parent
     self._output.library_listeners.discard_suite_scope()
Esempio n. 17
0
 def end_suite(self, suite):
     self._suite.message = self._suite_status.message
     self._context.report_suite_status(self._suite.status,
                                       self._suite.full_message)
     with self._context.suite_teardown():
         failure = self._run_teardown(suite.keywords.teardown,
                                      self._suite_status)
         if failure:
             self._suite.suite_teardown_failed(unic(failure))
             if self._suite.statistics.critical.failed:
                 self._suite_status.critical_failure_occurred()
     self._suite.endtime = get_timestamp()
     self._suite.message = self._suite_status.message
     self._context.end_suite(ModelCombiner(suite, self._suite))
     self._suite = self._suite.parent
     self._suite_status = self._suite_status.parent
     self._output.library_listeners.discard_suite_scope()
Esempio n. 18
0
 def start_suite(self, suite):
     self._output.library_listeners.new_suite_scope()
     result = TestSuite(source=suite.source,
                        name=suite.name,
                        doc=suite.doc,
                        metadata=suite.metadata,
                        starttime=get_timestamp(),
                        rpa=self._settings.rpa)
     if not self.result:
         result.set_criticality(self._settings.critical_tags,
                                self._settings.non_critical_tags)
         self.result = Result(root_suite=result, rpa=self._settings.rpa)
         self.result.configure(status_rc=self._settings.status_rc,
                               stat_config=self._settings.statistics_config)
     else:
         self._suite.suites.append(result)
     self._suite = result
     self._suite_status = SuiteStatus(self._suite_status,
                                      self._settings.exit_on_failure,
                                      self._settings.exit_on_error,
                                      self._settings.skip_teardown_on_exit)
     ns = Namespace(self._variables, result, suite.resource)
     ns.start_suite()
     ns.variables.set_from_variable_table(suite.resource.variables)
     EXECUTION_CONTEXTS.start_suite(result, ns, self._output,
                                    self._settings.dry_run)
     self._context.set_suite_variables(result)
     if not self._suite_status.failures:
         ns.handle_imports()
         ns.variables.resolve_delayed()
     result.doc = self._resolve_setting(result.doc)
     result.metadata = [(self._resolve_setting(n), self._resolve_setting(v))
                        for n, v in result.metadata.items()]
     self._context.set_suite_variables(result)
     self._output.start_suite(
         ModelCombiner(suite,
                       result,
                       tests=suite.tests,
                       suites=suite.suites,
                       test_count=suite.test_count))
     self._output.register_error_listener(self._suite_status.error_occurred)
     self._run_setup(suite.keywords.setup, self._suite_status)
     self._executed_tests = NormalizedDict(ignore='_')
Esempio n. 19
0
 def start_suite(self, suite):
     self._output.library_listeners.new_suite_scope()
     result = TestSuite(source=suite.source,
                        name=suite.name,
                        doc=suite.doc,
                        metadata=suite.metadata,
                        starttime=get_timestamp(),
                        rpa=self._settings.rpa)
     if not self.result:
         result.set_criticality(self._settings.critical_tags,
                                self._settings.non_critical_tags)
         self.result = Result(root_suite=result, rpa=self._settings.rpa)
         self.result.configure(status_rc=self._settings.status_rc,
                               stat_config=self._settings.statistics_config)
     else:
         self._suite.suites.append(result)
     self._suite = result
     self._suite_status = SuiteStatus(self._suite_status,
                                      self._settings.exit_on_failure,
                                      self._settings.exit_on_error,
                                      self._settings.skip_teardown_on_exit)
     ns = Namespace(self._variables, result, suite.resource)
     ns.start_suite()
     ns.variables.set_from_variable_table(suite.resource.variables)
     EXECUTION_CONTEXTS.start_suite(result, ns, self._output,
                                    self._settings.dry_run)
     self._context.set_suite_variables(result)
     if not self._suite_status.failures:
         ns.handle_imports()
         ns.variables.resolve_delayed()
     result.doc = self._resolve_setting(result.doc)
     result.metadata = [(self._resolve_setting(n), self._resolve_setting(v))
                        for n, v in result.metadata.items()]
     self._context.set_suite_variables(result)
     self._output.start_suite(ModelCombiner(suite, result,
                                            tests=suite.tests,
                                            suites=suite.suites,
                                            test_count=suite.test_count))
     self._output.register_error_listener(self._suite_status.error_occurred)
     self._run_setup(suite.keywords.setup, self._suite_status)
     self._executed_tests = NormalizedDict(ignore='_')
Esempio n. 20
0
 def __enter__(self):
     if self._context.test:
         self._test_passed = self._context.test.passed
     self._result.starttime = get_timestamp()
     self._context.start_keyword(self._result)
     self._warn_if_deprecated(self._result.doc, self._result.name)
Esempio n. 21
0
 def __enter__(self):
     if self._context.test:
         self._test_passed = self._context.test.passed
     self._result.starttime = get_timestamp()
     self._context.start_keyword(self._result)
     self._warn_if_deprecated(self._result.doc, self._result.name)
Esempio n. 22
0
 def __init__(self, message, level='INFO', html=False, timestamp=None):
     message = self._normalize_message(message)
     level, html = self._get_level_and_html(level, html)
     timestamp = timestamp or get_timestamp()
     BaseMessage.__init__(self, message, level, html, timestamp)
Esempio n. 23
0
 def __enter__(self):
     self._result.starttime = get_timestamp()
     self._context.start_keyword(self._result)