Ejemplo n.º 1
0
        def log_entry(depth, obj):
            name = obj['description'] if isinstance(obj, dict) else obj.name
            try:
                passed = obj['passed'] if isinstance(obj, dict) else obj.passed
            except KeyError:
                passed = True  # Some report entries (i.e. Log) always pass

            style = self.get_stdout_style(passed)
            display, indent = self.should_log_test_result(depth, obj, style)

            if display:
                if isinstance(obj, dict):
                    if obj['type'] == 'RawAssertion':
                        header = obj['description']
                        details = obj['content']
                    elif 'stdout_header' in obj and 'stdout_details' in obj:
                        header = obj['stdout_header']
                        details = obj['stdout_details']
                    else:
                        return
                    if style.display_assertion:
                        TESTPLAN_LOGGER.test_info(indent * ' ' + header)
                    if details and style.display_assertion_detail:
                        details = os.linesep.join(
                            (indent + 2) * ' ' + line
                            for line in details.split(os.linesep))
                        TESTPLAN_LOGGER.test_info(details)
                else:
                    msg = get_test_status_message(name=name, passed=passed)
                    TESTPLAN_LOGGER.test_info(indent * ' ' + msg)
Ejemplo n.º 2
0
    def log_test_results(self):

        report = self.result.report
        items = report.flatten(depths=True)

        for depth, obj in items:
            name = obj['description'] if isinstance(obj, dict) else obj.name
            passed = obj['passed'] if isinstance(obj, dict) else obj.passed

            style = self.get_stdout_style(passed)

            if self.should_log_test_result(depth, obj, style):
                indent = (depth + 1) * 2 * ' '
                msg = get_test_status_message(name=name, passed=passed)
                if isinstance(obj, dict) and style.display_assertion_detail:
                    detail_indent = indent + (2 * ' ')
                    detail_str = os.linesep.join(
                        '{}{}'.format(detail_indent, line)
                        for line in obj['content'].splitlines())

                    msg = '{}{}{}'.format(msg, os.linesep, detail_str)

                TESTPLAN_LOGGER.test_info('{indent}{msg}'.format(indent=indent,
                                                                 msg=msg))
Ejemplo n.º 3
0
def log_status(report, indent):
    msg = indent * ' ' + get_test_status_message(name=report.name,
                                                 passed=report.passed)
    TESTPLAN_LOGGER.test_info(msg)