Example #1
0
 def result(self, result):
     if not self.monochrome:
         lines = self.step_lines + 1
         if self.show_multiline:
             if result.table:
                 lines += self.table_lines
             if result.text:
                 lines += self.text_lines
         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:
         msg = result.error_message.strip()
         if isinstance(msg, str):
             try:
                 msg = msg.decode('ascii')
             except UnicodeDecodeError:
                 try:
                     msg = msg.decode('utf-8')
                 except UnicodeDecodeError:
                     try:
                         msg = msg.decode('latin1')
                     except UnicodeDecodeError:
                         msg = msg.decode('utf-8', errors='replace')
         indented = indent(msg, u'      ')
         self.stream.write(indented.encode('utf-8', errors='replace'))
         self.stream.write('\n\n')
     self.stream.flush()
Example #2
0
 def result(self, result):
     if not self.monochrome:
         lines = self.step_lines + 1
         if self.show_multiline:
             if result.table:
                 lines += self.table_lines
             if result.text:
                 lines += self.text_lines
         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:
         msg = result.error_message.strip()
         if isinstance(msg, str):
             try:
                 msg = msg.decode('ascii')
             except UnicodeDecodeError:
                 try:
                     msg = msg.decode('utf-8')
                 except UnicodeDecodeError:
                     try:
                         msg = msg.decode('latin1')
                     except UnicodeDecodeError:
                         msg = msg.decode('utf-8', errors='replace')
         indented = indent(msg, u'      ')
         self.stream.write(indented)
         self.stream.write('\n\n')
     self.stream.flush()
Example #3
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')
Example #4
0
 def doc_string(self, doc_string, strformat=unicode):
     triplequotes = self.format('comments').text(u'"""')
     self.text_lines = 2 + sum(
         [(1 + (6 + len(line)) // self.display_width)
          for line in doc_string.splitlines()])
     doc_string = strformat(escape_triple_quotes(doc_string))
     self.stream.write(indent(u'\n'.join([
         triplequotes, doc_string, triplequotes]), u'      ') + u'\n')
Example #5
0
 def doc_string(self, doc_string, strformat=unicode):
     triplequotes = self.format('comments').text(u'"""')
     self.text_lines = 2 + sum([(1 + (6 + len(line)) // self.display_width)
                                for line in doc_string.splitlines()])
     doc_string = strformat(escape_triple_quotes(doc_string))
     self.stream.write(
         indent(u'\n'.join([triplequotes, doc_string, triplequotes]),
                u'      ') + u'\n')
Example #6
0
 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()
Example #7
0
    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
Example #8
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()
Example #9
0
 def result(self, result):
     if not self.monochrome:
         lines = self.step_lines + 1
         if self.show_multiline:
             if result.table:
                 lines += self.table_lines
             if result.text:
                 lines += self.text_lines
         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()
Example #10
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')