Ejemplo n.º 1
0
def text_content(text):
    """Create a `Content` object from some text.

    This is useful for adding details which are short strings.
    """
    if _isbytes(text):
        raise TypeError('text_content must be given a string, not bytes.')
    return Content(UTF8_TEXT, lambda: [text.encode('utf8')])
Ejemplo n.º 2
0
def text_content(text):
    """Create a `Content` object from some text.

    This is useful for adding details which are short strings.
    """
    if _isbytes(text):
        raise TypeError('text_content must be given a string, not bytes.')
    return Content(UTF8_TEXT, lambda: [text.encode('utf8')])
Ejemplo n.º 3
0
 def __str__(self):
     difference = self.mismatch.describe()
     if self.verbose:
         # GZ 2011-08-24: Smelly API? Better to take any object and special
         #                case text inside?
         if istext(self.matchee) or _isbytes(self.matchee):
             matchee = text_repr(self.matchee, multiline=False)
         else:
             matchee = repr(self.matchee)
         return "Match failed. Matchee: %s\nMatcher: %s\nDifference: %s\n" % (matchee, self.matcher, difference)
     else:
         return difference
Ejemplo n.º 4
0
 def __str__(self):
     difference = self.mismatch.describe()
     if self.verbose:
         # GZ 2011-08-24: Smelly API? Better to take any object and special
         #                case text inside?
         if istext(self.matchee) or _isbytes(self.matchee):
             matchee = text_repr(self.matchee, multiline=False)
         else:
             matchee = repr(self.matchee)
         return (
             'Match failed. Matchee: %s\nMatcher: %s\nDifference: %s\n' %
             (matchee, self.matcher, difference))
     else:
         return difference
Ejemplo n.º 5
0
 def _format(self, thing):
     # Blocks of text with newlines are formatted as triple-quote
     # strings. Everything else is pretty-printed.
     if istext(thing) or _isbytes(thing):
         return text_repr(thing)
     return pformat(thing)
Ejemplo n.º 6
0
 def _format(self, thing):
     # Blocks of text with newlines are formatted as triple-quote
     # strings. Everything else is pretty-printed.
     if istext(thing) or _isbytes(thing):
         return text_repr(thing)
     return pformat(thing)