Пример #1
0
 def run(self):
     """Run a test in loop."""
     while (self.thread_signaller.running()):
         test_result = unittest.TestResult()
         self.test.clearContext()
         self.test(test_result)
         if test_result.wasSuccessful():
             if recording():
                 add_cycle_result('success')
                 if self.color:
                     trace(green_str('.'))
                 else:
                     trace('.')
         else:
             if len(test_result.errors):
                 if recording():
                     add_cycle_result('error')
                 if self.color:
                     trace(red_str('E'))
                 else:
                     trace('E')
             else:
                 if recording():
                     add_cycle_result('failure')
                 if self.color:
                     trace(red_str('F'))
                 else:
                     trace('F')
             if self.debug:
                 for (test, error) in test_result.errors:
                     trace("ERROR %s: %s" % (str(test), str(error)))
                 for (test, error) in test_result.failures:
                     trace("FAILURE %s: %s" % (str(test), str(error)))
         thread_sleep(self.sleep_time)
Пример #2
0
 def run(self, test):
     "Run the given test case or test suite."
     result = self._makeResult()
     startTime = time.time()
     test(result)
     stopTime = time.time()
     timeTaken = float(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()
     if not result.wasSuccessful():
         self.stream.write(red_str("FAILED") + " (")
         failed, errored = map(len, (result.failures, result.errors))
         if failed:
             self.stream.write("failures=%d" % failed)
         if errored:
             if failed:
                 self.stream.write(", ")
             self.stream.write("errors=%d" % errored)
         self.stream.writeln(")")
     else:
         self.stream.writeln(green_str("OK"))
     return result
Пример #3
0
    def run(self):
        """Run a test in loop."""
        while (self.thread_signaller.running()):
            test_result = unittest.TestResult()
            self.test.clearContext()
            self.test(test_result)
            feedback = {}

            if test_result.wasSuccessful():
                if recording():
                    feedback['count'] = add_cycle_result('success')

                if self.color:
                    trace(green_str('.'))
                else:
                    trace('.')

                feedback['result'] = 'success'
            else:
                if len(test_result.errors):
                    if recording():
                        feedback['count'] = add_cycle_result('error')

                    if self.color:
                        trace(red_str('E'))
                    else:
                        trace('E')

                    feedback['result'] = 'error'

                else:
                    if recording():
                        feedback['count'] = add_cycle_result('failure')

                    if self.color:
                        trace(red_str('F'))
                    else:
                        trace('F')

                    feedback['result'] = 'failure'

                if self.debug:
                    feedback['errors'] = test_result.errors
                    feedback['failures'] = test_result.failures

                    for (test, error) in test_result.errors:
                        trace("ERROR %s: %s" % (str(test), str(error)))
                    for (test, error) in test_result.failures:
                        trace("FAILURE %s: %s" % (str(test), str(error)))

            if self.feedback is not None:
                self.feedback.test_done(feedback)

            thread_sleep(self.sleep_time)
Пример #4
0
    def run(self):
        """Run a test in loop."""
        while self.thread_signaller.running():
            test_result = unittest.TestResult()
            self.test.clearContext()
            self.test(test_result)
            feedback = {}

            if test_result.wasSuccessful():
                if recording():
                    feedback["count"] = add_cycle_result("success")

                if self.color:
                    trace(green_str("."))
                else:
                    trace(".")

                feedback["result"] = "success"
            else:
                if len(test_result.errors):
                    if recording():
                        feedback["count"] = add_cycle_result("error")

                    if self.color:
                        trace(red_str("E"))
                    else:
                        trace("E")

                    feedback["result"] = "error"

                else:
                    if recording():
                        feedback["count"] = add_cycle_result("failure")

                    if self.color:
                        trace(red_str("F"))
                    else:
                        trace("F")

                    feedback["result"] = "failure"

                if self.debug:
                    feedback["errors"] = test_result.errors
                    feedback["failures"] = test_result.failures

                    for (test, error) in test_result.errors:
                        trace("ERROR %s: %s" % (str(test), str(error)))
                    for (test, error) in test_result.failures:
                        trace("FAILURE %s: %s" % (str(test), str(error)))

            if self.feedback is not None:
                self.feedback.test_done(feedback)

            thread_sleep(self.sleep_time)
Пример #5
0
def get_status(success, failures, errors, color=False):
    """Return a status and an exit code."""
    if errors:
        status = 'ERROR'
        if color:
            status = red_str(status)
        code = -1
    elif failures:
        status = 'FAILURE'
        if color:
            status = red_str(status)
        code = 1
    else:
        status = 'SUCCESSFUL'
        if color:
            status = green_str(status)
        code = 0
    return status, code
Пример #6
0
 def write(self, arg):
     if arg in ['OK', 'Ok', 'ok', '.']:
         arg = green_str(arg)
     elif arg in ['ERROR', 'E', 'FAILED', 'FAIL', 'F']:
         arg = red_str(arg)
     sys.stderr.write(arg)
Пример #7
0
 def addSuccess(self, test):
     unittest.TestResult.addSuccess(self, test)
     if self.showAll:
         self.stream.writeln(green_str("Ok"))
     elif self.dots:
         self.stream.write(green_str("."))
Пример #8
0
 def addSuccess(self, test):
     unittest.TestResult.addSuccess(self, test)
     if self.showAll:
         self.stream.writeln(green_str("Ok"))
     elif self.dots:
         self.stream.write(green_str('.'))
Пример #9
0
 def write(self, arg):
     if arg in ['OK', 'Ok', 'ok', '.']:
         arg = green_str(arg)
     elif arg in ['ERROR', 'E', 'FAILED', 'FAIL', 'F']:
         arg = red_str(arg)
     sys.stderr.write(arg)