Ejemplo n.º 1
0
    def __repr__(self):
        name = getattr(self.c, '__module__', '')
        if name:
            name += '.'
        name += getattr(self.c, '__name__', '')
        if not name:
            name = repr(self.c)

        text = ''
        if self.failed:
            text = self.failed
        elif self.v:
            lines = []
            for k, v in sorted(self.v.items()):
                rv = repr(v)
                if '\n' in rv:
                    rv = indent(rv)
                lines.append('%s: %s' % (k, rv))
            text = '\n'.join(lines)
            if len(lines) > 1:
                text = '\n'+text

        r = '<C%s:%s>' % (self.failed and '(failed)' or '', name)
        if '\n' in text:
            r = '\n'+r+text+'\n'
        else:
            r += text
        if text:
            r += '</C>'

        return r
Ejemplo n.º 2
0
    def __repr__(self):
        name = getattr(self.c, '__module__', '')
        if name:
            name += '.'
        name += getattr(self.c, '__name__', '')
        if not name:
            name = repr(self.c)

        text = ''
        if self.failed:
            text = self.failed
        elif self.v:
            lines = []
            for k, v in sorted(self.v.items()):
                rv = repr(v)
                if '\n' in rv:
                    rv = indent(rv)
                lines.append('%s: %s' % (k, rv))
            text = '\n'.join(lines)
            if len(lines) > 1:
                text = '\n' + text

        r = '<C%s:%s>' % (self.failed and '(failed)' or '', name)
        if '\n' in text:
            r = '\n' + r + text + '\n'
        else:
            r += text
        if text:
            r += '</C>'

        return r
Ejemplo n.º 3
0
 def body(self):
     if self.expected_attributes:
         # if we're not failed, show what we will expect:
         lines = []
         for k, v in sorted(self.expected_attributes.items()):
             rv = repr(v)
             if '\n' in rv:
                 rv = indent(rv)
             lines.append('%s: %s' % (k, rv))
         return '\n'.join(lines)
     return ''