示例#1
0
文件: pretty.py 项目: akinnane/behave
    def print_description(self, description, indentation, newline=True):
        if not description:
            return

        self.stream.write(indent(description, indentation))
        if newline:
            self.stream.write('\n')
示例#2
0
    def print_comments(self, comments, indentation):
        if not comments:
            return

        text = indent([c.value for c in comments], indentation)
        self.writer.write(text, style="comments")
        self.writer.write('\n')
示例#3
0
    def describe_table(table, indentation=None):
        """
        Provide a textual description of the table (as used w/ Gherkin).

        :param table:  Table to use (as :class:`behave.model.Table`)
        :param indentation:  Line prefix to use (as string, if any).
        :return: Textual table description (as unicode string).
        """
        # -- STEP: Determine output size of all cells.
        cell_lengths = []
        all_rows = [table.headings] + table.rows
        for row in all_rows:
            lengths = [len(escape_cell(c)) for c in row]
            cell_lengths.append(lengths)

        # -- STEP: Determine max. output size for each column.
        max_lengths = []
        for col in range(0, len(cell_lengths[0])):
            max_lengths.append(max([c[col] for c in cell_lengths]))

        # -- STEP: Build textual table description.
        lines = []
        for r, row in enumerate(all_rows):
            line = "|"
            for c, (cell, max_length) in enumerate(zip(row, max_lengths)):
                pad_size = max_length - cell_lengths[r][c]
                line += " %s%s |" % (escape_cell(cell), " " * pad_size)
            line += "\n"
            lines.append(line)

        if indentation:
            return indent(lines, indentation)
        # -- OTHERWISE:
        return "".join(lines)
示例#4
0
    def print_comments(self, comments, indentation):
        if not comments:
            return

        text = indent([c.value for c in comments], indentation)
        self.writer.write(text, style="comments")
        self.writer.write('\n')
示例#5
0
    def describe_table(table, indentation=None):
        """
        Provide a textual description of the table (as used w/ Gherkin).

        :param table:  Table to use (as :class:`behave.model.Table`)
        :param indentation:  Line prefix to use (as string, if any).
        :return: Textual table description (as unicode string).
        """
        # -- STEP: Determine output size of all cells.
        cell_lengths = []
        all_rows = [table.headings] + table.rows
        for row in all_rows:
            lengths = [len(escape_cell(c)) for c in row]
            cell_lengths.append(lengths)

        # -- STEP: Determine max. output size for each column.
        max_lengths = []
        for col in range(0, len(cell_lengths[0])):
            max_lengths.append(max([c[col] for c in cell_lengths]))

        # -- STEP: Build textual table description.
        lines = []
        for r, row in enumerate(all_rows):
            line = "|"
            for c, (cell, max_length) in enumerate(zip(row, max_lengths)):
                pad_size = max_length - cell_lengths[r][c]
                line += " %s%s |" % (escape_cell(cell), " " * pad_size)
            line += "\n"
            lines.append(line)

        if indentation:
            return indent(lines, indentation)
        # -- OTHERWISE:
        return "".join(lines)
示例#6
0
    def print_description(self, description, indentation, newline=True):
        if not description:
            return

        self.stream.write(indent(description, indentation))
        if newline:
            self.stream.write('\n')
示例#7
0
文件: pretty.py 项目: xbx/behave
 def doc_string(self, doc_string):
     #self.stream.write('      """' + doc_string.content_type + '\n')
     prefix = '      '
     self.stream.write('%s"""\n' % prefix)
     doc_string = escape_triple_quotes(indent(doc_string, prefix))
     self.stream.write(doc_string)
     self.stream.write('\n%s"""\n' % prefix)
     self.stream.flush()
示例#8
0
    def print_description(self, description, indentation, newline=True):
        if not description:
            return

        self.writer.write(indent(description, indentation),
                          style="description")
        if newline:
            self.writer.write('\n')
示例#9
0
文件: pretty.py 项目: biznixcn/behave
 def doc_string(self, doc_string):
     #self.stream.write('      """' + doc_string.content_type + '\n')
     prefix = '      '
     self.stream.write('%s"""\n' % prefix)
     doc_string = escape_triple_quotes(indent(doc_string, prefix))
     self.stream.write(doc_string)
     self.stream.write('\n%s"""\n' % prefix)
     self.stream.flush()
示例#10
0
    def print_description(self, description, indentation, newline=True):
        if not description:
            return

        self.writer.write(indent(description, indentation),
                            style="description")
        if newline:
            self.writer.write('\n')
示例#11
0
文件: pretty.py 项目: behave/behave
 def doc_string(self, doc_string):
     #self.stream.write('      """' + doc_string.content_type + '\n')
     doc_string = _text(doc_string)
     prefix = u"      "
     if self.current_rule:
         prefix += u"  "
     self.stream.write(u'%s"""\n' % prefix)
     doc_string = escape_triple_quotes(indent(doc_string, prefix))
     self.stream.write(doc_string)
     self.stream.write(u'\n%s"""\n' % prefix)
     self.stream.flush()
示例#12
0
 def doc_string(self, doc_string):
     #self.stream.write('      """' + doc_string.content_type + '\n')
     doc_string = _text(doc_string)
     prefix = u"      "
     if self.current_rule:
         prefix += u"  "
     self.stream.write(u'%s"""\n' % prefix)
     doc_string = escape_triple_quotes(indent(doc_string, prefix))
     self.stream.write(doc_string)
     self.stream.write(u'\n%s"""\n' % prefix)
     self.stream.flush()
示例#13
0
    def result(self, result):
        if self.use_step_replay:
            lines = self.printer.step_lines + 1
            self.terminal.move_cursor_up(lines)

        self.print_step(result.status, proceed=True)
        # XXX
        if result.error_message:
            error_message = indent(result.error_message.strip(), u'      ')
            self.terminal.write(error_message, style="error")
            self.terminal.write('\n\n')
        self.terminal.flush()
        self._match = None
示例#14
0
    def result(self, result):
        if self.use_step_replay:
            lines = self.printer.step_lines + 1
            self.terminal.move_cursor_up(lines)

        self.print_step(result.status, proceed=True)
        # XXX
        if result.error_message:
            error_message = indent(result.error_message.strip(), u'      ')
            self.terminal.write(error_message, style="error")
            self.terminal.write('\n\n')
        self.terminal.flush()
        self._match = None
示例#15
0
文件: steps.py 项目: Abdoctor/behave
 def write_step_definition(self, step_definition):
     step_definition_text = self.describe_step_definition(step_definition)
     self.stream.write(u"%s\n" % step_definition_text)
     doc = inspect.getdoc(step_definition.func)
     func_name = step_definition.func.__name__
     if self.shows_function_name and func_name not in ("step", "impl"):
         self.stream.write(u"  Function: %s()\n" % func_name)
     if self.shows_location:
         self.stream.write(u"  Location: %s\n" % step_definition.location)
     if doc:
         doc = doc.strip()
         self.stream.write(indent(doc, self.doc_prefix))
         self.stream.write("\n")
     self.stream.write("\n")
示例#16
0
 def write_step_definition(self, step_definition):
     step_definition_text = self.describe_step_definition(step_definition)
     self.stream.write(u"%s\n" % step_definition_text)
     doc = inspect.getdoc(step_definition.func)
     func_name = step_definition.func.__name__
     if self.shows_function_name and func_name not in ("step", "impl"):
         self.stream.write(u"  Function: %s()\n" % func_name)
     if self.shows_location:
         self.stream.write(u"  Location: %s\n" % step_definition.location)
     if doc:
         doc = doc.strip()
         self.stream.write(indent(doc, self.doc_prefix))
         self.stream.write("\n")
     self.stream.write("\n")
示例#17
0
    def describe_docstring(doc_string, indentation=None):
        """
        Provide a textual description of the multi-line text/triple-quoted
        doc-string (as used w/ Gherkin).

        :param doc_string:  Multi-line text to use.
        :param indentation:  Line prefix to use (as string, if any).
        :return: Textual table description (as unicode string).
        """
        text = escape_triple_quotes(doc_string)
        text = '"""\n' + text + '\n"""\n'

        if indentation:
            text = indent(text, indentation)
        return text
示例#18
0
    def describe_docstring(doc_string, indentation=None):
        """
        Provide a textual description of the multi-line text/triple-quoted
        doc-string (as used w/ Gherkin).

        :param doc_string:  Multi-line text to use.
        :param indentation:  Line prefix to use (as string, if any).
        :return: Textual table description (as unicode string).
        """
        text = escape_triple_quotes(doc_string)
        text = '"""\n' + text + '\n"""\n'

        if indentation:
            text = indent(text, indentation)
        return text
示例#19
0
文件: junit.py 项目: florentx/behave
    def describe_scenario(cls, scenario):
        """
        Describe the scenario and the test status.
        NOTE: table, multiline text is missing in description.

        :param scenario:  Scenario that was tested.
        :return: Textual description of the scenario.
        """
        header_line  = u'\[email protected]\n'
        header_line += '  %s: %s\n' % (scenario.keyword, scenario.name)
        footer_line  = u'\[email protected]\n' + u'-' * 80 + '\n'
        text = u''
        for step in scenario:
            text += cls.describe_step(step)
        step_indentation = make_indentation(4)
        return header_line + indent(text, step_indentation) + footer_line
示例#20
0
    def result(self, result):
        if self.use_step_replay:
            lines = self.printer.step_lines + 1
            self.terminal.move_cursor_up(lines)

        status_name = result.status
        if Status:
            # -- SINCE: behave 1.2.6 with Status enum class
            status_name = result.status.name
        self.print_step(status_name, proceed=True)
        if result.error_message:
            error_message = indent(result.error_message.strip(), u'      ')
            self.terminal.write(error_message, style="error")
            self.terminal.write('\n\n')
        self.terminal.flush()
        self._match = None
示例#21
0
    def result(self, result):
        if self.use_step_replay:
            lines = self.printer.step_lines + 1
            self.terminal.move_cursor_up(lines)

        status_name = result.status
        if Status:
            # -- SINCE: behave 1.2.6 with Status enum class
            status_name = result.status.name
        self.print_step(status_name, proceed=True)
        if result.error_message:
            error_message = indent(result.error_message.strip(), u'      ')
            self.terminal.write(error_message, style="error")
            self.terminal.write('\n\n')
        self.terminal.flush()
        self._match = None
示例#22
0
文件: junit.py 项目: xbx/behave
    def describe_scenario(cls, scenario):
        """
        Describe the scenario and the test status.
        NOTE: table, multiline text is missing in description.

        :param scenario:  Scenario that was tested.
        :return: Textual description of the scenario.
        """
        header_line  = u'\[email protected]\n'
        header_line += '  %s: %s\n' % (scenario.keyword, scenario.name)
        footer_line  = u'\[email protected]\n' + u'-' * 80 + '\n'
        text = u''
        for step in scenario:
            text += cls.describe_step(step)
        step_indentation = make_indentation(4)
        return header_line + indent(text, step_indentation) + footer_line
示例#23
0
    def describe_scenario(self, scenario):
        """Describe the scenario and the test status.
        NOTE: table, multiline text is missing in description.

        :param scenario:  Scenario that was tested.
        :return: Textual description of the scenario.
        """
        header_line = '\[email protected]\n'
        if self.show_tags and scenario.tags:
            header_line += '\n  %s\n' % self.describe_tags(scenario.tags)
        header_line += '  %s: %s\n' % (scenario.keyword, scenario.name)
        footer_line = '\[email protected]\n' + '-' * 80 + '\n'
        text = ''
        for step in scenario:
            text += self.describe_step(step)
        step_indentation = make_indentation(4)
        return header_line + indent(text, step_indentation) + footer_line
示例#24
0
文件: junit.py 项目: s1ider/behave
    def describe_scenario(cls, scenario):
        """
        Describe the scenario and the test status.
        NOTE: table, multiline text is missing in description.

        :param scenario:  Scenario that was tested.
        :return: Textual description of the scenario.
        """
        header_line = u"\[email protected]\n"
        if cls.show_tags and scenario.tags:
            header_line += u"\n  %s\n" % cls.describe_tags(scenario.tags)
        header_line += u"  %s: %s\n" % (scenario.keyword, scenario.name)
        footer_line = u"\[email protected]\n" + u"-" * 80 + "\n"
        text = u""
        for step in scenario:
            text += cls.describe_step(step)
        step_indentation = make_indentation(4)
        return header_line + indent(text, step_indentation) + footer_line
示例#25
0
 def result(self, result):
     if not self.monochrome:
         lines = self.step_lines + 1
         if self.show_multiline:
             if result.table:
                 lines += len(result.table.rows) + 1
             if result.text:
                 lines += len(result.text.splitlines()) + 2
         self.stream.write(up(lines))
     arguments = []
     location = None
     if self._match:
         arguments = self._match.arguments
         location = self._match.location
     self.print_step(result.status, arguments, location, True)
     if result.error_message:
         self.stream.write(indent(result.error_message.strip(), u'      '))
         self.stream.write('\n\n')
     self.stream.flush()
示例#26
0
文件: pretty.py 项目: akinnane/behave
 def result(self, result):
     if not self.monochrome:
         lines = self.step_lines + 1
         if self.show_multiline:
             if result.table:
                 lines += len(result.table.rows) + 1
             if result.text:
                 lines += len(result.text.splitlines()) + 2
         self.stream.write(up(lines))
         arguments = []
         location = None
         if self._match:
             arguments = self._match.arguments
             location = self._match.location
         self.print_step(result.status, arguments, location, True)
     if result.error_message:
         self.stream.write(indent(result.error_message.strip(), u'      '))
         self.stream.write('\n\n')
     self.stream.flush()
示例#27
0
def report_testcases(filename, testcases):
    print(u"REPORT: {0}".format(filename))
    for xml_testcase in testcases:
        print("  TESTCASE: {0}".format(xml_testcase.get("name")))
        xml_text = indent(xml_prettify(xml_testcase), "    ")
        print(xml_text)
示例#28
0
    def print_comments(self, comments, indentation):
        if not comments:
            return

        self.stream.write(indent([c.value for c in comments], indentation))
        self.stream.write('\n')
示例#29
0
def report_testcases(filename, testcases):
    print(u"REPORT: {0}".format(filename))
    for xml_testcase in testcases:
        print("  TESTCASE: {0}".format(xml_testcase.get("name")))
        xml_text = indent(xml_prettify(xml_testcase), "    ")
        print(xml_text)
示例#30
0
文件: pretty.py 项目: akinnane/behave
    def print_comments(self, comments, indentation):
        if not comments:
            return

        self.stream.write(indent([c.value for c in comments], indentation))
        self.stream.write('\n')