Beispiel #1
0
def print_table(rows, headers, nicks, order):
    """Print a fancy table"""

    rows.insert(0, headers)
    rows = filter_table(rows, nicks, order)
    if not rows:
        return

    widths = []
    for c in range(len(rows[0])):
        widths.append(max(map(lambda r: len(r[c]), rows)))

    seperator = " %s " % Colorise.gray("|")
    format_string = seperator.join(["%%-%ds" % w for w in widths])

    header = []
    for i, h in enumerate(rows.pop(0)):
        header.append(h.ljust(widths[i], " "))
    line_width = len("   ".join(header)) + 2
    header = [Colorise.bold(h) for h in header]
    header_line = " " + (" %s " % Colorise.gray("|")).join(header)

    print_(header_line.rstrip())
    print_(Colorise.gray("-" * line_width))

    for row in rows:
        print_(" " + (format_string % tuple(row)).rstrip())
Beispiel #2
0
 def printErrors(self):
     succ = self.testsRun - (len(self.errors) + len(self.failures))
     v = Colorise.bold("%3d" % succ)
     cv = Colorise.green(v) if succ == self.testsRun else Colorise.red(v)
     count = self.TEST_RESULTS_WIDTH - self.testsRun
     print_((" " * count) + cv)
     self.printErrorList('ERROR', self.errors)
     self.printErrorList('FAIL', self.failures)
Beispiel #3
0
 def printErrors(self):
     succ = self.testsRun - (len(self.errors) + len(self.failures))
     v = Colorise.bold("%3d" % succ)
     cv = Colorise.green(v) if succ == self.testsRun else Colorise.red(v)
     count = self.TEST_RESULTS_WIDTH - self.testsRun
     print_((" " * count) + cv)
     self.printErrorList('ERROR', self.errors)
     self.printErrorList('FAIL', self.failures)
 def __init__(self, test_name, num_tests, out=sys.stdout):
     super(Result, self).__init__()
     self.out = out
     if hasattr(out, "flush"):
         out.flush()
     pref = '%s (%d): ' % (Colorise.bold(test_name), num_tests)
     line = pref + " " * (self.TEST_NAME_WIDTH - len(test_name) - 6 -
                          int(num_tests and log(num_tests, 10) or 0))
     print_(line, end="")
Beispiel #5
0
 def __init__(self, test_name, num_tests, out=sys.stdout, failfast=False):
     super(Result, self).__init__()
     self.out = out
     self.failfast = failfast
     if hasattr(out, "flush"):
         out.flush()
     pref = "%s (%d): " % (Colorise.bold(test_name), num_tests)
     line = pref + " " * (self.TEST_NAME_WIDTH - len(test_name) - 7 - int(num_tests and log(num_tests, 10) or 0))
     print_(line, end="")