[pypy-svn] r9931 - pypy/dist/lib-python-2.3.4/test

hpk at codespeak.net hpk at codespeak.net
Sun Mar 20 17:18:40 CET 2005


Author: hpk
Date: Sun Mar 20 17:18:40 2005
New Revision: 9931

Modified:
   pypy/dist/lib-python-2.3.4/test/conftest.py
Log:
call test_main() if it exists in order to hack out the
list of classes that are to be tested. 



Modified: pypy/dist/lib-python-2.3.4/test/conftest.py
==============================================================================
--- pypy/dist/lib-python-2.3.4/test/conftest.py	(original)
+++ pypy/dist/lib-python-2.3.4/test/conftest.py	Sun Mar 20 17:18:40 2005
@@ -95,18 +95,30 @@
                 ...]
     """ 
     #print "entering list_testmethods"
-    l = []
-    for clsname, cls in mod.__dict__.items(): 
-        if hasattr(cls, '__bases__') and \
-           issubclass(cls, testcaseclass): 
-            instance = cls() 
-            #print "checking", instance 
-            methods = []
-            for methodname in dir(cls): 
-                if methodname.startswith('test_'): 
-                    name = clsname + '.' + methodname 
-                    methods.append((name, getattr(instance, methodname)))
-            l.append((instance.setUp, instance.tearDown, methods))
+    classlist = []
+    if callable(getattr(mod, 'test_main', None)): 
+        def hack_run_unittest(*classes): 
+            classlist.extend(list(classes))
+        mod.test_support.run_unittest = hack_run_unittest 
+        mod.test_main() 
+        mod.test_support.run_unittest = None 
+    else: 
+        # we try to find out fitting tests ourselves 
+        for clsname, cls in mod.__dict__.items(): 
+            if hasattr(cls, '__bases__') and \
+               issubclass(cls, testcaseclass): 
+                classlist.append(cls) 
+    l = [] 
+    for cls in classlist: 
+        clsname = cls.__name__
+        instance = cls() 
+        #print "checking", instance 
+        methods = []
+        for methodname in dir(cls): 
+            if methodname.startswith('test_'): 
+                name = clsname + '.' + methodname 
+                methods.append((name, getattr(instance, methodname)))
+        l.append((instance.setUp, instance.tearDown, methods))
     return l 
 list_testmethods = app2interp_temp(app_list_testmethods) 
            



More information about the Pypy-commit mailing list