예제 #1
0
    def run(self, test):
        "Run the given test case or test suite."
        result = self._makeResult()
        result.failfast = self.failfast
        result.buffer = self.buffer
        result.tb_locals = self.tb_locals
        registerResult(result)

        startTime = time.time()
        startTestRun = getattr(result, 'startTestRun', None)
        if startTestRun is not None:
            startTestRun()
        try:
            test(result)
        finally:
            stopTestRun = getattr(result, 'stopTestRun', None)
            if stopTestRun is not None:
                stopTestRun()
            else:
                result.printErrors()
        stopTime = time.time()
        timeTaken = stopTime - startTime
        if hasattr(result, 'separator2'):
            self.stream.writeln(result.separator2)
        run = result.testsRun
        self.stream.writeln(u("Ran %d test%s in %.3fs") %
                            (run, run != 1 and "s" or "", timeTaken))
        self.stream.writeln()

        expectedFails = unexpectedSuccesses = skipped = 0
        try:
            results = map(len, (result.expectedFailures,
                                result.unexpectedSuccesses,
                                result.skipped))
        except AttributeError:
            pass
        else:
            expectedFails, unexpectedSuccesses, skipped = results
        infos = []
        if not result.wasSuccessful():
            self.stream.write(u("FAILED"))
            failed, errored = map(len, (result.failures, result.errors))
            if failed:
                infos.append(u("failures=%d") % failed)
            if errored:
                infos.append(u("errors=%d") % errored)
        else:
            self.stream.write(u("OK"))
        if skipped:
            infos.append(u("skipped=%d") % skipped)
        if expectedFails:
            infos.append(u("expected failures=%d") % expectedFails)
        if unexpectedSuccesses:
            infos.append(u("unexpected successes=%d") % unexpectedSuccesses)
        if infos:
            self.stream.writeln(u(" (%s)") % (u(", ").join(infos),))
        else:
            self.stream.write(u("\n"))
        return result
예제 #2
0
    def run(self, test):
        "Run the given test case or test suite."
        result = self._makeResult()
        result.failfast = self.failfast
        result.buffer = self.buffer
        result.tb_locals = self.tb_locals
        registerResult(result)

        startTime = time.time()
        startTestRun = getattr(result, 'startTestRun', None)
        if startTestRun is not None:
            startTestRun()
        try:
            test(result)
        finally:
            stopTestRun = getattr(result, 'stopTestRun', None)
            if stopTestRun is not None:
                stopTestRun()
            else:
                result.printErrors()
        stopTime = time.time()
        timeTaken = stopTime - startTime
        if hasattr(result, 'separator2'):
            self.stream.writeln(result.separator2)
        run = result.testsRun
        self.stream.writeln(u("Ran %d test%s in %.3fs") %
                            (run, run != 1 and "s" or "", timeTaken))
        self.stream.writeln()

        expectedFails = unexpectedSuccesses = skipped = 0
        try:
            results = map(len, (result.expectedFailures,
                                result.unexpectedSuccesses,
                                result.skipped))
        except AttributeError:
            pass
        else:
            expectedFails, unexpectedSuccesses, skipped = results
        infos = []
        if not result.wasSuccessful():
            self.stream.write(u("FAILED"))
            failed, errored = map(len, (result.failures, result.errors))
            if failed:
                infos.append(u("failures=%d") % failed)
            if errored:
                infos.append(u("errors=%d") % errored)
        else:
            self.stream.write(u("OK"))
        if skipped:
            infos.append(u("skipped=%d") % skipped)
        if expectedFails:
            infos.append(u("expected failures=%d") % expectedFails)
        if unexpectedSuccesses:
            infos.append(u("unexpected successes=%d") % unexpectedSuccesses)
        if infos:
            self.stream.writeln(u(" (%s)") % (u(", ").join(infos),))
        else:
            self.stream.write(u("\n"))
        return result
예제 #3
0
파일: runner.py 프로젝트: CodaFi/swift-lldb
    def run(self, test):
        "Run the given test case or test suite."
        result = self._makeResult()
        result.failfast = self.failfast
        result.buffer = self.buffer
        registerResult(result)

        startTime = time.time()
        startTestRun = getattr(result, 'startTestRun', None)
        if startTestRun is not None:
            startTestRun()
        try:
            test(result)
        finally:
            stopTestRun = getattr(result, 'stopTestRun', None)
            if stopTestRun is not None:
                stopTestRun()
            else:
                result.printErrors()
        stopTime = time.time()
        timeTaken = stopTime - startTime
        if hasattr(result, 'separator2'):
            self.stream.writeln(result.separator2)
        run = result.testsRun
        self.stream.writeln("Ran %d test%s in %.3fs" %
                            (run, run != 1 and "s" or "", timeTaken))
        self.stream.writeln()

        expectedFails = unexpectedSuccesses = skipped = passed = failed = errored = 0
        try:
            results = map(len, (result.expectedFailures,
                                result.unexpectedSuccesses,
                                result.skipped,
                                result.passes,
                                result.failures,
                                result.errors))
            expectedFails, unexpectedSuccesses, skipped, passed, failed, errored = results
        except AttributeError:
            pass
        infos = []
        infos.append("%d passes" % passed)
        infos.append("%d failures" % failed)
        infos.append("%d errors" % errored)
        infos.append("%d skipped" % skipped)
        infos.append("%d expected failures" % expectedFails)
        infos.append("%d unexpected successes" % unexpectedSuccesses)
        self.stream.write("RESULT: ")
        if not result.wasSuccessful():
            self.stream.write("FAILED")
        else:
            self.stream.write("PASSED")

        self.stream.writeln(" (%s)" % (", ".join(infos),))
        return result
    def run(self, test):
        "Run the given test case or test suite."
        result = self._makeResult()
        result.failfast = self.failfast
        result.buffer = self.buffer
        registerResult(result)

        startTime = time.time()
        startTestRun = getattr(result, 'startTestRun', None)
        if startTestRun is not None:
            startTestRun()
        try:
            test(result)
        finally:
            stopTestRun = getattr(result, 'stopTestRun', None)
            if stopTestRun is not None:
                stopTestRun()
            else:
                result.printErrors()
        stopTime = time.time()
        timeTaken = stopTime - startTime
        if hasattr(result, 'separator2'):
            self.stream.writeln(result.separator2)
        run = result.testsRun
#        self.stream.writeln("Ran %d test%s in %.3fs" %
#                            (run, run != 1 and "s" or "", timeTaken))
#        self.stream.writeln()

        expectedFails = unexpectedSuccesses = skipped = passed = failed = errored = 0
        try:
            results = map(len, (result.expectedFailures,
                                result.unexpectedSuccesses,
                                result.skipped,
                                result.passes,
                                result.failures,
                                result.errors))
            expectedFails, unexpectedSuccesses, skipped, passed, failed, errored = results
        except AttributeError:
            pass
        infos = []
        infos.append("%d passes" % passed)
        infos.append("%d failures" % failed)
        infos.append("%d errors" % errored)
        infos.append("%d skipped" % skipped)
        infos.append("%d expected failures" % expectedFails)
        infos.append("%d unexpected successes" % unexpectedSuccesses)
        self.stream.write("RESULT: ")
        if not result.wasSuccessful():
            self.stream.write("FAILED")
        else:
            self.stream.write("PASSED")

        self.stream.writeln(" (%s)" % (", ".join(infos),))
        return result
예제 #5
0
    def run(self, test):
        "Run the given test case or test suite."
        result = self._makeResult()
        result.failfast = self.failfast
        result.buffer = self.buffer
        registerResult(result)
        
        startTime = time.time()
        startTestRun = getattr(result, 'startTestRun', None)
        if startTestRun is not None:
            startTestRun()
        try:
            test(result)
        finally:
            stopTestRun = getattr(result, 'stopTestRun', None)
            if stopTestRun is not None:
                stopTestRun()
            else:
                result.printErrors()
        stopTime = time.time()
        timeTaken = stopTime - startTime
        if hasattr(result, 'separator2'):
            self.stream.writeln(result.separator2)
        run = result.testsRun
        self.stream.writeln("Ran {0:d} test{1!s} in {2:.3f}s".format(run, run != 1 and "s" or "", timeTaken))
        self.stream.writeln()
        
        expectedFails = unexpectedSuccesses = skipped = passed = failed = errored = 0
        try:
            results = map(len, (result.expectedFailures,
                                result.unexpectedSuccesses,
                                result.skipped,
                                result.passes,
                                result.failures,
                                result.errors))
            expectedFails, unexpectedSuccesses, skipped, passed, failed, errored = results
        except AttributeError:
            pass
        infos = []
        infos.append("{0:d} passes".format(passed))
        infos.append("{0:d} failures".format(failed))
        infos.append("{0:d} errors".format(errored))
        infos.append("{0:d} skipped".format(skipped))
        infos.append("{0:d} expected failures".format(expectedFails))
        infos.append("{0:d} unexpected successes".format(unexpectedSuccesses))
        self.stream.write("RESULT: ")
        if not result.wasSuccessful():
            self.stream.write("FAILED")
        else:
            self.stream.write("PASSED")

        self.stream.writeln(" ({0!s})".format(", ".join(infos)))
        return result
예제 #6
0
    def run(self, test):
        """Run the given test case or test suite."""
        result = self._makeResult()
        startTime = time.time()
        startTestRun = getattr(result, 'startTestRun', None)
        if startTestRun is not None:
            startTestRun()
        try:
            test(result)
        finally:
            stopTestRun = getattr(result, 'stopTestRun', None)
            if stopTestRun is not None:
                stopTestRun()

        stopTime = time.time()
        timeTaken = stopTime - startTime
        result.printErrors()
        self.stream.writeln(result.separator2)
        run = result.testsRun
        self.stream.writeln('Ran %d test%s in %.3fs' %
                            (run, run != 1 and 's' or '', timeTaken))
        self.stream.writeln()
        results = map(len, (result.expectedFailures,
                            result.unexpectedSuccesses, result.skipped))
        expectedFails, unexpectedSuccesses, skipped = results
        infos = []
        if not result.wasSuccessful():
            self.stream.write('FAILED')
            failed, errored = map(len, (result.failures, result.errors))
            if failed:
                infos.append('failures=%d' % failed)
            if errored:
                infos.append('errors=%d' % errored)
        else:
            self.stream.write('OK')
        if skipped:
            infos.append('skipped=%d' % skipped)
        if expectedFails:
            infos.append('expected failures=%d' % expectedFails)
        if unexpectedSuccesses:
            infos.append('unexpected successes=%d' % unexpectedSuccesses)
        if infos:
            self.stream.writeln(' (%s)' % (', '.join(infos), ))
        else:
            self.stream.write('\n')
        return result
예제 #7
0
파일: runner.py 프로젝트: Pluckyduck/eve
    def run(self, test):
        result = self._makeResult()
        startTime = time.time()
        startTestRun = getattr(result, 'startTestRun', None)
        if startTestRun is not None:
            startTestRun()
        try:
            test(result)
        finally:
            stopTestRun = getattr(result, 'stopTestRun', None)
            if stopTestRun is not None:
                stopTestRun()

        stopTime = time.time()
        timeTaken = stopTime - startTime
        result.printErrors()
        self.stream.writeln(result.separator2)
        run = result.testsRun
        self.stream.writeln('Ran %d test%s in %.3fs' % (run, run != 1 and 's' or '', timeTaken))
        self.stream.writeln()
        results = map(len, (result.expectedFailures, result.unexpectedSuccesses, result.skipped))
        expectedFails, unexpectedSuccesses, skipped = results
        infos = []
        if not result.wasSuccessful():
            self.stream.write('FAILED')
            failed, errored = map(len, (result.failures, result.errors))
            if failed:
                infos.append('failures=%d' % failed)
            if errored:
                infos.append('errors=%d' % errored)
        else:
            self.stream.write('OK')
        if skipped:
            infos.append('skipped=%d' % skipped)
        if expectedFails:
            infos.append('expected failures=%d' % expectedFails)
        if unexpectedSuccesses:
            infos.append('unexpected successes=%d' % unexpectedSuccesses)
        if infos:
            self.stream.writeln(' (%s)' % (', '.join(infos),))
        else:
            self.stream.write('\n')
        return result
예제 #8
0
    def run(self, test):
        "Run the given test case or test suite."
        result = self._makeResult()
        result.failfast = self.failfast
        result.buffer = self.buffer
        registerResult(result)
        
        startTime = time.time()
        startTestRun = getattr(result, 'startTestRun', None)
        if startTestRun is not None:
            startTestRun()
        
        executor = lambda suite, result: test(result)
        event = StartTestRunEvent(self, test, result, startTime, executor)
        hooks.startTestRun(event)
        
        # allows startTestRun to modify test suite
        test = event.suite
        executor = event.executeTests
        try:
            if not event.handled:
                executor(test, result)
        finally:
            stopTime = time.time()
            timeTaken = stopTime - startTime

            event = StopTestRunEvent(self, result, stopTime, timeTaken)
            hooks.stopTestRun(event)

            stopTestRun = getattr(result, 'stopTestRun', None)
            if stopTestRun is not None:
                stopTestRun()
            else:
                result.printErrors()

        reportEvent = ReportEvent(self, result)
        hooks.beforeSummaryReport(reportEvent)
        if hasattr(result, 'separator2'):
            self.message(result.separator2, (0, 1, 2))
            self.message('\n')
        run = result.testsRun
        msg = ("Ran %d test%s in %.3fs\n\n" %
                            (run, run != 1 and "s" or "", timeTaken))
        self.message(msg, (0, 1, 2))
        
        infos = []
        extraInfos = []
        if result.wasSuccessful():
            self.message("OK", (0, 1, 2))
        else:
            self.message("FAILED", (0, 1, 2))

        if not hasattr(result, 'reportCategories'):
            expectedFails = unexpectedSuccesses = skipped = 0
            try:
                results = map(len, (result.expectedFailures,
                                    result.unexpectedSuccesses,
                                    result.skipped))
                expectedFails, unexpectedSuccesses, skipped = results
            except AttributeError:
                pass
            failed, errored = map(len, (result.failures, result.errors))
        else:
            failed = len(result.reportCategories.get('failed', []))
            errored = len(result.reportCategories.get('error', []))
            skipped = len(result.reportCategories.get('skipped', []))
            expectedFails = len(result.reportCategories.get('expectedFails', []))
            unexpectedSuccesses = len(result.reportCategories.get('unexpectedSuccesses', []))
            
            dontReport = set(['error', 'failed', 'skipped', 'passed',
                              'expectedFailures', 'unexpectedSuccess'])
            for flavour, results in result.reportCategories.items():
                if flavour in dontReport:
                    continue
                extraInfos.append("%s=%d" % (flavour, len(results)))

        if failed:
            infos.append("failures=%d" % failed)
        if errored:
            infos.append("errors=%d" % errored)
        if skipped:
            infos.append("skipped=%d" % skipped)
        if expectedFails:
            infos.append("expected failures=%d" % expectedFails)
        if unexpectedSuccesses:
            infos.append("unexpected successes=%d" % unexpectedSuccesses)
        infos.extend(extraInfos)
        if infos:
            self.message(" (%s)" % (", ".join(infos),), (0, 1, 2))
        self.message("\n")
        hooks.afterSummaryReport(reportEvent)
        return result