Exemplo n.º 1
0
class Results(object):

    def __init__(self, data_sources, settings):
        self._data_sources = data_sources \
            if not isinstance(data_sources, basestring) else [data_sources]
        self._settings = settings
        self._result = None
        self._js_result = None
        self.return_code = -1

    @property
    def result(self):
        if self._result is None:
            self._result = ExecutionResult(*self._data_sources)
            self._result.configure(self._settings.status_rc,
                                   self._settings.suite_config,
                                   self._settings.statistics_config)
            self.return_code = self._result.return_code
        return self._result

    @property
    def js_result(self):
        if self._js_result is None:
            builder = JsModelBuilder(log_path=self._settings.log,
                                     split_log=self._settings.split_log,
                                     prune_input_to_save_memory=True)
            self._js_result = builder.build_from(self.result)
            self._result = None
        return self._js_result
Exemplo n.º 2
0
class Results(object):
    def __init__(self, data_sources, settings):
        self._data_sources = data_sources \
            if not isinstance(data_sources, basestring) else [data_sources]
        self._settings = settings
        self._result = None
        self._js_result = None
        self.return_code = -1

    @property
    def result(self):
        if self._result is None:
            self._result = ExecutionResult(*self._data_sources)
            self._result.configure(self._settings.status_rc,
                                   self._settings.suite_config,
                                   self._settings.statistics_config)
            self.return_code = self._result.return_code
        return self._result

    @property
    def js_result(self):
        if self._js_result is None:
            builder = JsModelBuilder(log_path=self._settings.log,
                                     split_log=self._settings.split_log,
                                     prune_input_to_save_memory=True)
            self._js_result = builder.build_from(self.result)
            self._result = None
        return self._js_result
Exemplo n.º 3
0
 def test_rpa(self):
     rpa_false = GOLDEN_XML
     self._validate_rpa(ExecutionResult(StringIO(rpa_false)), False)
     self._validate_rpa(ExecutionResult(StringIO(rpa_false), rpa=True), True)
     rpa_true = GOLDEN_XML.replace('rpa="false"', 'rpa="true"')
     self._validate_rpa(ExecutionResult(StringIO(rpa_true)), True)
     self._validate_rpa(ExecutionResult(StringIO(rpa_true), rpa=False), False)
Exemplo n.º 4
0
 def result(self):
     if self._result is None:
         self._result = ExecutionResult(*self._data_sources)
         self._result.configure(self._settings.status_rc,
                                self._settings.suite_config,
                                self._settings.statistics_config)
         self.return_code = self._result.return_code
     return self._result
Exemplo n.º 5
0
 def result(self):
     if self._result is None:
         include_keywords = bool(self._settings.log
                                 or self._settings.output)
         self._result = ExecutionResult(include_keywords=include_keywords,
                                        *self._sources)
         self._result.configure(self._settings.status_rc,
                                self._settings.suite_config,
                                self._settings.statistics_config)
         self.return_code = self._result.return_code
     return self._result
Exemplo n.º 6
0
 def setUp(self):
     self.result = """
     <robot>
         <suite name="foo">
             <test name="some name">
                 <status status="PASS"></status>
             </test>
         <status status="PASS"></status>
         </suite>
     </robot>
     """
     self.string_result = ExecutionResult(self.result)
     self.byte_string_result = ExecutionResult(self.result.encode('UTF-8'))
Exemplo n.º 7
0
 def result(self):
     if self._result is None:
         include_keywords = bool(self._settings.log or self._settings.output)
         flattened = self._settings.flatten_keywords
         rerun_merge = self._settings.rerun_merge
         self._result = ExecutionResult(include_keywords=include_keywords,
                                        flattened_keywords=flattened,
                                        rerun_merge=rerun_merge,
                                        *self._sources)
         self._result.configure(self._settings.status_rc,
                                self._settings.suite_config,
                                self._settings.statistics_config)
         self.return_code = self._result.return_code
     return self._result
class Results(object):
    def __init__(self, settings, *sources):
        self._settings = settings
        self._sources = sources
        if len(sources) == 1 and isinstance(sources[0], Result):
            self._result = sources[0]
            self._prune = False
            self.return_code = self._result.return_code
        else:
            self._result = None
            self._prune = True
            self.return_code = -1
        self._js_result = None

    @property
    def result(self):
        if self._result is None:
            include_keywords = bool(self._settings.log
                                    or self._settings.output)
            flattened = self._settings.flatten_keywords
            self._result = ExecutionResult(include_keywords=include_keywords,
                                           flattened_keywords=flattened,
                                           merge=self._settings.merge,
                                           rpa=self._settings.rpa,
                                           *self._sources)
            if self._settings.rpa is None:
                self._settings.rpa = self._result.rpa
            modifier = ModelModifier(self._settings.pre_rebot_modifiers,
                                     self._settings.process_empty_suite,
                                     LOGGER)
            self._result.suite.visit(modifier)
            self._result.configure(self._settings.status_rc,
                                   self._settings.suite_config,
                                   self._settings.statistics_config)
            self.return_code = self._result.return_code
        return self._result

    @property
    def js_result(self):
        if self._js_result is None:
            builder = JsModelBuilder(
                log_path=self._settings.log,
                split_log=self._settings.split_log,
                expand_keywords=self._settings.expand_keywords,
                prune_input_to_save_memory=self._prune)
            self._js_result = builder.build_from(self.result)
            if self._prune:
                self._result = None
        return self._js_result
Exemplo n.º 9
0
def gather_failed_tests(output):
    if output.upper() == 'NONE':
        return []
    gatherer = GatherFailedTests()
    tests_or_tasks = 'tests or tasks'
    try:
        suite = ExecutionResult(output, include_keywords=False).suite
        suite.visit(gatherer)
        tests_or_tasks = 'tests' if not suite.rpa else 'tasks'
        if not gatherer.tests:
            raise DataError('All %s passed.' % tests_or_tasks)
    except:
        raise DataError("Collecting failed %s from '%s' failed: %s" %
                        (tests_or_tasks, output, get_error_message()))
    return gatherer.tests
Exemplo n.º 10
0
def gather_failed_tests(output):
    if output.upper() == 'NONE':
        return []
    gatherer = GatherFailedTests()
    tests_or_tasks = 'tests or tasks'
    try:
        suite = ExecutionResult(output, include_keywords=False).suite
        suite.visit(gatherer)
        tests_or_tasks = 'tests' if not suite.rpa else 'tasks'
        if not gatherer.tests:
            raise DataError('All %s passed.' % tests_or_tasks)
    except:
        raise DataError("Collecting failed %s from '%s' failed: %s"
                        % (tests_or_tasks, output, get_error_message()))
    return gatherer.tests
Exemplo n.º 11
0
def gather_failed_tests(output, empty_suite_ok=False):
    if output is None:
        return None
    gatherer = GatherFailedTests()
    tests_or_tasks = 'tests or tasks'
    try:
        suite = ExecutionResult(output, include_keywords=False).suite
        suite.visit(gatherer)
        tests_or_tasks = 'tests' if not suite.rpa else 'tasks'
        if not gatherer.tests and not empty_suite_ok:
            raise DataError('All %s passed.' % tests_or_tasks)
    except Exception:
        raise DataError("Collecting failed %s from '%s' failed: %s" %
                        (tests_or_tasks, output, get_error_message()))
    return gatherer.tests
Exemplo n.º 12
0
def process_file(inpath, outpath, items):
    suite = ExecutionResult(inpath).suite
    with open(outpath, 'w', newline='') as outfile:
        writer = csv.writer(outfile, delimiter=';')
        writer.writerow(['TYPE', 'NAME', 'STATUS', 'START', 'END', 'ELAPSED',
                         'ELAPSED SECS'])
        process_suite(suite, writer, items.lower())
Exemplo n.º 13
0
 def test_with_increasing_cut_from_end(self):
     input = open(os.path.join('test', 'orig-output.xml')).read()
     while len(input) > 250:
         input = input[:-10]
         fixxxed = fixml.Fixxxer(input)
         suite = ExecutionResult(str(fixxxed)).suite
         assert_equals(suite.name, 'Suite')
Exemplo n.º 14
0
 def setUp(self):
     result = ExecutionResult(StringIO(GOLDEN_XML),
                              StringIO(GOLDEN_XML),
                              StringIO(GOLDEN_XML),
                              merge=True)
     self.suite = result.suite
     self.test = self.suite.tests[0]
Exemplo n.º 15
0
 def test_already_processed(self):
     inp = SUITE_TEARDOWN_FAILED.replace('generator="Robot', 'generator="Rebot')
     tc1, tc2 = ExecutionResult(StringIO(inp)).suite.tests
     assert_equals(tc1.status, 'PASS')
     assert_equals(tc1.message, '')
     assert_equals(tc2.status, 'FAIL')
     assert_equals(tc2.message, 'Message')
Exemplo n.º 16
0
class Results(object):

    def __init__(self, settings, *sources):
        self._settings = settings
        self._sources = sources
        if len(sources) == 1 and isinstance(sources[0], Result):
            self._result = sources[0]
            self._prune = False
            self.return_code = self._result.return_code
        else:
            self._result = None
            self._prune = True
            self.return_code = -1
        self._js_result = None

    @property
    def result(self):
        if self._result is None:
            include_keywords = bool(self._settings.log or self._settings.output)
            flattened = self._settings.flatten_keywords
            self._result = ExecutionResult(include_keywords=include_keywords,
                                           flattened_keywords=flattened,
                                           merge=self._settings.merge,
                                           rpa=self._settings.rpa,
                                           *self._sources)
            if self._settings.rpa is None:
                self._settings.rpa = self._result.rpa
            self._result.configure(self._settings.status_rc,
                                   self._settings.suite_config,
                                   self._settings.statistics_config)
            modifier = ModelModifier(self._settings.pre_rebot_modifiers,
                                     self._settings.process_empty_suite,
                                     LOGGER)
            self._result.suite.visit(modifier)
            self.return_code = self._result.return_code
        return self._result

    @property
    def js_result(self):
        if self._js_result is None:
            builder = JsModelBuilder(log_path=self._settings.log,
                                     split_log=self._settings.split_log,
                                     prune_input_to_save_memory=self._prune)
            self._js_result = builder.build_from(self.result)
            if self._prune:
                self._result = None
        return self._js_result
Exemplo n.º 17
0
 def result(self):
     if self._result is None:
         include_keywords = bool(self._settings.log or self._settings.output)
         flattened = self._settings.flatten_keywords
         self._result = ExecutionResult(include_keywords=include_keywords,
                                        flattened_keywords=flattened,
                                        merge=self._settings.merge,
                                        *self._sources)
         self._result.configure(self._settings.status_rc,
                                self._settings.suite_config,
                                self._settings.statistics_config)
         modifier = ModelModifier(self._settings.pre_rebot_modifiers,
                                  self._settings.process_empty_suite,
                                  LOGGER)
         self._result.suite.visit(modifier)
         self.return_code = self._result.return_code
     return self._result
Exemplo n.º 18
0
 def result(self):
     if self._result is None:
         self._result = ExecutionResult(*self._data_sources)
         self._result.configure(self._settings.status_rc,
                                self._settings.suite_config,
                                self._settings.statistics_config)
         self.return_code = self._result.return_code
     return self._result
Exemplo n.º 19
0
def process_file(inpath, outpath, items):
    suite = ExecutionResult(inpath).suite
    outfile = open(outpath, 'wb')
    writer = csv.writer(outfile)
    writer.writerow(['TYPE', 'NAME', 'STATUS', 'START', 'END', 'ELAPSED',
                     'ELAPSED SECS'])
    process_suite(suite, writer, items.lower())
    outfile.close()
Exemplo n.º 20
0
 def setUp(self):
     result = ExecutionResult(StringIO(GOLDEN_XML))
     self._suite = result.suite
     self._test = self._suite.tests[0]
     self._keyword = self._test.keywords[0]
     self._user_keyword = self._test.keywords[1]
     self._message = self._keyword.messages[0]
     self._setup = self._suite.keywords[0]
     self._errors = result.errors
Exemplo n.º 21
0
 def test_already_processed(self):
     inp = SUITE_TEARDOWN_FAILED.replace('generator="Robot', 'generator="Rebot')
     passed, failed, teardowns = ExecutionResult(StringIO(inp)).suite.tests
     assert_equal(passed.status, 'PASS')
     assert_equal(passed.message, '')
     assert_equal(failed.status, 'FAIL')
     assert_equal(failed.message, 'Message')
     assert_equal(teardowns.status, 'PASS')
     assert_equal(teardowns.message, '')
Exemplo n.º 22
0
 def setUp(self):
     self.result = ExecutionResult(StringIO(GOLDEN_XML))
     self.suite = self.result.suite
     self.test = self.suite.tests[0]
     self.keyword = self.test.keywords[0]
     self.user_keyword = self.test.keywords[1]
     self.message = self.keyword.messages[0]
     self.setup = self.suite.keywords[0]
     self.errors = self.result.errors
Exemplo n.º 23
0
 def result(self):
     if self._result is None:
         include_keywords = bool(self._settings.log or self._settings.output)
         self._result = ExecutionResult(include_keywords=include_keywords,
                                        *self._sources)
         self._result.configure(self._settings.status_rc,
                                self._settings.suite_config,
                                self._settings.statistics_config)
         self.return_code = self._result.return_code
     return self._result
Exemplo n.º 24
0
 def test_save(self):
     temp = os.getenv('TEMPDIR', tempfile.gettempdir())
     path = Path(temp) / 'pathlib.xml'
     self.result.save(path)
     try:
         result = ExecutionResult(path)
     finally:
         path.unlink()
     self.test_suite_is_built(result.suite)
     self.test_test_is_built(result.suite)
Exemplo n.º 25
0
 def test_suite_message(self):
     xml = """
     <robot>
     <suite name="foo">
       <status status="FAIL">Setup failed</status>
     </suite>
     </robot>
     """
     suite = ExecutionResult(StringIO(xml)).suite
     assert_equal(suite.message, 'Setup failed')
Exemplo n.º 26
0
    def overwrite_output_file(self):
        """ Method removes all dummy test results from output.xml file together with messages related with those tests
        It overwrites output.xml file generated by robot executor
        :return: None
        """
        result = ExecutionResult(self.output_file_path)
        result.suite.tests = [test for test in result.suite.tests if self.REMOVE_NAME.lower() not in test.name.lower()]

        ResultWriter(result).write_results(
            output=self.output_file_path, report=self.report_file_path, log=self.logger_file_path
        )
Exemplo n.º 27
0
    def setUp(self):
        self.result = ExecutionResult("""
<robot>
    <suite name="foo">
        <test name="some name">
            <status status="PASS"></status>
        </test>
    <status status="PASS"></status>
    </suite>
</robot>
""")
Exemplo n.º 28
0
class Results(object):
    def __init__(self, settings, *sources):
        self._settings = settings
        self._sources = sources
        if len(sources) == 1 and isinstance(sources[0], Result):
            self._result = sources[0]
            self._prune = False
            self.return_code = self._result.return_code
        else:
            self._result = None
            self._prune = True
            self.return_code = -1
        self._js_result = None

    @property
    def result(self):
        if self._result is None:
            include_keywords = bool(self._settings.log
                                    or self._settings.output)
            flattened = self._settings.flatten_keywords
            rerun_merge = self._settings.rerun_merge
            self._result = ExecutionResult(include_keywords=include_keywords,
                                           flattened_keywords=flattened,
                                           rerun_merge=rerun_merge,
                                           *self._sources)
            self._result.configure(self._settings.status_rc,
                                   self._settings.suite_config,
                                   self._settings.statistics_config)
            self.return_code = self._result.return_code
        return self._result

    @property
    def js_result(self):
        if self._js_result is None:
            builder = JsModelBuilder(log_path=self._settings.log,
                                     split_log=self._settings.split_log,
                                     prune_input_to_save_memory=self._prune)
            self._js_result = builder.build_from(self.result)
            if self._prune:
                self._result = None
        return self._js_result
Exemplo n.º 29
0
def gather_failed_suites(output, empty_suite_ok=False):
    if output is None:
        return None
    gatherer = GatherFailedSuites()
    try:
        ExecutionResult(output, include_keywords=False).suite.visit(gatherer)
        if not gatherer.suites and not empty_suite_ok:
            raise DataError('All suites passed.')
    except Exception:
        raise DataError("Collecting failed suites from '%s' failed: %s" %
                        (output, get_error_message()))
    return gatherer.suites
Exemplo n.º 30
0
def gather_failed_tests(output):
    if output.upper() == 'NONE':
        return []
    gatherer = GatherFailedTests()
    try:
        ExecutionResult(output).suite.visit(gatherer)
        if not gatherer.tests:
            raise DataError('All tests passed.')
    except:
        raise DataError("Collecting failed tests from '%s' failed: %s" %
                        (output, get_error_message()))
    return gatherer.tests
Exemplo n.º 31
0
 def test_excluding_keywords_and_already_processed(self):
     inp = SUITE_TEARDOWN_FAILED.replace('generator="Robot', 'generator="Rebot')
     suite = ExecutionResult(StringIO(inp), include_keywords=False).suite
     passed, failed, teardowns = suite.tests
     assert_equal(passed.status, 'PASS')
     assert_equal(passed.message, '')
     assert_equal(failed.status, 'FAIL')
     assert_equal(failed.message, 'Message')
     assert_equal(teardowns.status, 'PASS')
     assert_equal(teardowns.message, '')
     for item in suite, passed, failed, teardowns:
         assert_equal(list(item.keywords), [])
Exemplo n.º 32
0
    def test_result_is_built(self):
        xml = """
<robot>
    <suite name="foo">
        <test name="some name">
            <status status="PASS"></status>
        </test>
    <status status="PASS"></status>
    </suite>
</robot>
""".strip()
        result = ExecutionResult(xml)
def gather_failed_suites(output):
    if output.upper() == 'NONE':
        return []
    gatherer = RenameThenGatherFailedSuites()
    try:
        ExecutionResult(output, include_keywords=False).suite.visit(gatherer)
        if not gatherer.suites:
            raise DataError('All suites passed.')
    except:
        raise DataError("Collecting failed suites from '%s' failed: %s"
                        % (output, get_error_message()))
    return gatherer.suites
Exemplo n.º 34
0
 def test_excluding_keywords(self):
     suite = ExecutionResult(StringIO(SUITE_TEARDOWN_FAILED),
                             include_keywords=False).suite
     passed, failed, teardowns = suite.tests
     assert_equal(passed.status, 'FAIL')
     assert_equal(passed.message, 'Parent suite teardown failed:\nXXX')
     assert_equal(failed.status, 'FAIL')
     assert_equal(failed.message, 'Message\n\n'
                  'Also parent suite teardown failed:\nXXX')
     assert_equal(teardowns.status, 'FAIL')
     assert_equal(teardowns.message, 'Parent suite teardown failed:\nXXX')
     for item in suite, passed, failed, teardowns:
         assert_equal(list(item.keywords), [])
    class TestUsingPathlibPath(unittest.TestCase):
        def setUp(self):
            self.result = ExecutionResult(
                pathlib.Path(join(dirname(__file__), 'golden.xml')))

        def test_suite_is_built(self, suite=None):
            suite = suite or self.result.suite
            assert_equal(suite.source, 'normal.html')
            assert_equal(suite.name, 'Normal')
            assert_equal(suite.doc, 'Normal test cases')
            assert_equal(suite.metadata, {'Something': 'My Value'})
            assert_equal(suite.status, 'PASS')
            assert_equal(suite.starttime, '20111024 13:41:20.873')
            assert_equal(suite.endtime, '20111024 13:41:20.952')
            assert_equal(suite.statistics.passed, 1)
            assert_equal(suite.statistics.failed, 0)

        def test_test_is_built(self, suite=None):
            test = (suite or self.result.suite).tests[0]
            assert_equal(test.name, 'First One')
            assert_equal(test.doc, 'Test case documentation')
            assert_equal(test.timeout, None)
            assert_equal(list(test.tags), ['t1'])
            assert_equal(len(test.body), 4)
            assert_equal(test.status, 'PASS')
            assert_equal(test.starttime, '20111024 13:41:20.925')
            assert_equal(test.endtime, '20111024 13:41:20.934')

        def test_save(self):
            temp = os.getenv('TEMPDIR', tempfile.gettempdir())
            path = pathlib.Path(temp) / 'pathlib.xml'
            self.result.save(path)
            try:
                result = ExecutionResult(path)
            finally:
                path.unlink()
            self.test_suite_is_built(result.suite)
            self.test_test_is_built(result.suite)
Exemplo n.º 36
0
class Results(object):

    def __init__(self, settings, *sources):
        self._settings = settings
        self._sources = sources
        if len(sources) == 1 and isinstance(sources[0], Result):
            self._result = sources[0]
            self._prune = False
            self.return_code = self._result.return_code
        else:
            self._result = None
            self._prune = True
            self.return_code = -1
        self._js_result = None

    @property
    def result(self):
        if self._result is None:
            include_keywords = bool(self._settings.log or self._settings.output)
            self._result = ExecutionResult(include_keywords=include_keywords,
                                           *self._sources)
            self._result.configure(self._settings.status_rc,
                                   self._settings.suite_config,
                                   self._settings.statistics_config)
            self.return_code = self._result.return_code
        return self._result

    @property
    def js_result(self):
        if self._js_result is None:
            builder = JsModelBuilder(log_path=self._settings.log,
                                     split_log=self._settings.split_log,
                                     prune_input_to_save_memory=self._prune)
            self._js_result = builder.build_from(self.result)
            if self._prune:
                self._result = None
        return self._js_result
Exemplo n.º 37
0
 def result(self):
     if self._result is None:
         include_keywords = bool(self._settings.log or self._settings.output)
         flattened = self._settings.flatten_keywords
         self._result = ExecutionResult(include_keywords=include_keywords,
                                        flattened_keywords=flattened,
                                        merge=self._settings.merge,
                                        *self._sources)
         self._result.configure(self._settings.status_rc,
                                self._settings.suite_config,
                                self._settings.statistics_config)
         modifier = ModelModifier(self._settings.pre_rebot_modifiers,
                                  self._settings.process_empty_suite,
                                  LOGGER)
         self._result.suite.visit(modifier)
         self.return_code = self._result.return_code
     return self._result
Exemplo n.º 38
0
def check_tests(inpath, outpath=None):
    if not outpath:
        outpath = inpath
    result = ExecutionResult(inpath)
    _check_execution_times(result.suite)
    result.save(outpath)
def process_output(inpath, outpath=None):
    result = ExecutionResult(inpath)
    _process_suite(result.suite)
    result.save(outpath)
    return result.return_code