Commits

Rune Halvorsen committed a23db88

Added (an ugly) nose-like logger

Comments (0)

Files changed (1)

         print "Finished. %s/%s tests failed" % (failures, total)
         self.is_done = True
 
-def NoseLikeLogger(BaseLogger):
-    pass
+class NoseLikeLogger(BaseLogger):
+    def __init__(self, *args, **kwargs):
+        self.logcnt = 1
+        self.errors = []
+        self.current_test = None
+        self.starttime = None
+        self.uastring = None
+
+    def start(self, uastring):
+        self.starttime = time.time()
+        self.uastring = uastring
+
+    def console(self, msgtype, msg):
+        print "\nconsole.%s: %s" % (msgtype, msg)
+
+    def moduleStart(self, name):
+        pass
+
+    def testStart(self, name):
+        self.current_test = name
+        self.logcnt = 1
+
+    def log(self, result, message):
+        if message == "failed":
+            sys.stdout.write("F")
+            self.errors.append((self.current_test, result, message))
+        else:
+            sys.stdout.write(".")
+        self.logcnt += 1
+        sys.stdout.flush()
+
+    def testDone(self, name, failures, total):
+        pass
+
+    def moduleDone(self, name, failures, total):
+        pass
+
+    def done(self, failures, total):
+        for name, result, message in self.errors:
+            print """\n======================================================================
+FAIL: %s
+----------------------------------------------------------------------\n%s\n""" % (name, message)
+
+        print "\nRan %s tests in %.3fs (Using %s)" % (total, time.time() - self.starttime, self.uastring)
+        self.is_done = True
+
+
+
+
+
 
 
 class SilentWSGIRequestHandler(WSGIRequestHandler):
         pass
 
 def build_app(root, options):
-    app = GlueonApp(root, SimplePrintLogger, testdoc=options.testdoc)
+    app = GlueonApp(root, NoseLikeLogger, testdoc=options.testdoc)
     app = SharedDataMiddleware(app, {'/suite': root},
                                cache=False, disallow="*.html")
     return app