[pypy-svn] rev 2616 - pypy/trunk/src/pypy/tool

sschwarzer at codespeak.net sschwarzer at codespeak.net
Sat Dec 20 10:08:19 CET 2003


Author: sschwarzer
Date: Sat Dec 20 10:08:18 2003
New Revision: 2616

Modified:
   pypy/trunk/src/pypy/tool/newtest.py
Log:
Simplify implementation of test_runner support.


Modified: pypy/trunk/src/pypy/tool/newtest.py
==============================================================================
--- pypy/trunk/src/pypy/tool/newtest.py	(original)
+++ pypy/trunk/src/pypy/tool/newtest.py	Sat Dec 20 10:08:18 2003
@@ -332,24 +332,25 @@
         return id(self.module) ^ id(self.cls)
 
     # credit: adapted from Python's unittest.TestCase.run
-    def run(self, test_runner=None):
+    def run(self, test_runner=lambda callable: callable()):
         """
         Run this TestItem and return a corresponding TestResult object.
-        
+
         If the test item corresponds to a class method, the setUp and
         tearDown methods of the associated class are called before and
         after the invocation of the test method, repectively.
 
-        If the optional argument test_runner is None, the test function
+        If the optional argument test_runner is absent, the test function
         or method is merely called with no arguments. Else, test_runner
         must be a callable accepting one argument. Instead of only calling
         the test callable, the test_runner object will be called with the
         test function/method as its argument.
         """
         if self._isfunction:
+            # use the test function directly
             test = self.callable
         else:
-            # make the test callable a bound method
+            # turn the test callable, an unbound method, into a bound method
             cls_object = self.cls()
             test = getattr(cls_object, self.callable.__name__)
 
@@ -365,10 +366,7 @@
             return Error(msg=str(exc), item=self)
 
         try:
-            if test_runner is None:
-                test()
-            else:
-                test_runner(test)
+            test_runner(test)
             result = Success(msg='success', item=self)
         except KeyboardInterrupt:
             raise


More information about the Pypy-commit mailing list