Пример #1
0
def make_human_readable_result(stream):
    """Make a result that emits messages intended for human consumption."""
    def print_result(test, status, start_time, stop_time, tags, details):
        testid = "<none>" if test is None else test.id()
        duration = (stop_time - start_time).total_seconds()
        message = "%s: %s (%0.2fs)" % (status.upper(), testid, abs(duration))
        print(message, file=stream, flush=True)

    return testtools.MultiTestResult(
        testtools.TextTestResult(stream, failfast=False, tb_locals=False),
        testtools.TestByTestResult(print_result))
Пример #2
0
    def __init__(self, tree, name, command, fail_quickly=False):
        super(SubunitTreeStageBuilder, self).__init__(tree, name, command,
                                                      fail_quickly)
        self.failed_test = None
        self.subunit_path = os.path.join(
            gitroot, "%s.%s.subunit" % (self.tree.tag, self.name))
        self.tree.logfiles.append(
            (self.subunit_path, os.path.basename(self.subunit_path),
             "text/x-subunit"))
        self.subunit = open(self.subunit_path, 'w')

        formatter = subunithelper.PlainFormatter(False, True, {})
        clients = [
            formatter,
            subunit.TestProtocolClient(self.subunit),
            FailureTrackingTestResult(self)
        ]
        if fail_quickly:
            clients.append(AbortingTestResult(self))
        self.subunit_server = subunit.TestProtocolServer(
            testtools.MultiTestResult(*clients), self.subunit)
        self.buffered = ""
Пример #3
0
            x.split(':')[0].strip() + '.html'
            for x in args.load_list.readlines()))
else:
    tests = []

# Collect summary of all the individual test runs
summary = testtools.StreamSummary()

# Output information to stdout
if not args.subunit:
    # Human readable test output
    pertest = testtools.StreamToExtendedDecorator(
        testtools.MultiTestResult(
            # Individual test progress
            unittest.TextTestResult(
                unittest.runner._WritelnDecorator(sys.stdout), False, 2),
            # End of run, summary of failures.
            testtools.TextTestResult(sys.stdout),
        ))
else:
    from subunit.v2 import StreamResultToBytes
    pertest = StreamResultToBytes(sys.stdout)

    if args.list:
        output = subunit.CopyStreamResult([summary, pertest])
        output.startTestRun()
        for test in re.compile("(?<=').+(?=')").findall(
                file("test/testcases.js").read()):
            output.status(test_status='exists', test_id=test[:-5])

        output.stopTestRun()
Пример #4
0
summary = testtools.StreamSummary()

# Output information to stdout
if not args.subunit:
    # Output test failures
    result_streams = [testtools.TextTestResult(sys.stdout)]
    if args.verbose:
        import unittest
        # Output individual test progress
        result_streams.insert(
            0,
            unittest.TextTestResult(
                unittest.runner._WritelnDecorator(sys.stdout), False, 2))
    # Human readable test output
    pertest = testtools.StreamToExtendedDecorator(
        testtools.MultiTestResult(*result_streams))
else:
    from subunit.v2 import StreamResultToBytes
    pertest = StreamResultToBytes(sys.stdout)

    if args.list:
        output = subunit.CopyStreamResult([summary, pertest])
        output.startTestRun()
        for test in re.compile("(?<=').+(?=')").findall(
                file("test/testcases.js").read()):
            output.status(test_status='exists', test_id=test[:-5])

        output.stopTestRun()
        sys.exit(-1)

output = subunit.CopyStreamResult([summary, pertest])