Browse Source

tests: print out exceptions and keep going when a method test fails

Mark Yen 12 years ago
parent
commit
6b28ad6b0f
1 changed files with 12 additions and 5 deletions
  1. 12 5
      xpcom/test/test_test_component.py

+ 12 - 5
xpcom/test/test_test_component.py

@@ -35,7 +35,7 @@
 #
 #
 # ***** END LICENSE BLOCK *****
 # ***** END LICENSE BLOCK *****
 
 
-import sys, os, time
+import sys, os, time, traceback
 import xpcom.components
 import xpcom.components
 import xpcom._xpcom
 import xpcom._xpcom
 import xpcom.nsError
 import xpcom.nsError
@@ -135,10 +135,17 @@ def test_attribute_failure(ob, attr_name, new_value, expected_exception):
 def test_method(method, args, expected_results):
 def test_method(method, args, expected_results):
     if xpcom.verbose:
     if xpcom.verbose:
         print "Testing %s%s" % (method.__name__, `args`)
         print "Testing %s%s" % (method.__name__, `args`)
-    ret = method(*args)
-    if ret != expected_results:
-        print_error("calling method %s with %r - expected %r, but got %r" %
-                    (method.__name__, args, expected_results, ret))
+    try:
+        ret = method(*args)
+    except Exception, ex:
+        print_error("calling method %s with %r - exception:" %
+                    (method.__name__, args))
+        traceback.print_exc(None, sys.stdout)
+    else:
+        if ret != expected_results:
+            print_error("calling method %s with %r - expected %r, but got %r" %
+                        (method.__name__, args, expected_results, ret))
+    sys.stdout.flush()
 
 
 def test_int_method(meth):
 def test_int_method(meth):
     test_method(meth, (0,0), (0,0,0))
     test_method(meth, (0,0), (0,0,0))