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

sschwarzer at codespeak.net sschwarzer at codespeak.net
Fri Dec 19 11:49:26 CET 2003


Author: sschwarzer
Date: Fri Dec 19 11:49:25 2003
New Revision: 2549

Modified:
   pypy/trunk/src/pypy/tool/newtest.py
Log:
TestSuite._items_from_module: Use issubclass instead of wrong isinstance to
find TestCase classes. Also, import newtest locally to make sure that this
method and modules import newtest refer to the same TestCase class.

Note: Module doesn't work right now.


Modified: pypy/trunk/src/pypy/tool/newtest.py
==============================================================================
--- pypy/trunk/src/pypy/tool/newtest.py	(original)
+++ pypy/trunk/src/pypy/tool/newtest.py	Fri Dec 19 11:49:25 2003
@@ -324,12 +324,14 @@
 
     def _items_from_module(self, module):
         """Return a list of TestItems read from the given module."""
+        # make sure that this method and modules import newtest refer
+        # to the same TestCase class
+        from pypy.tool import newtest
+
         items = []
         # scan the module for classes derived from TestCase
         for obj in vars(module).values():
-            if inspect.isclass(obj):
-                print obj, id(obj)
-            if inspect.isclass(obj) and isinstance(obj, TestCase):
+            if inspect.isclass(obj) and issubclass(obj, newtest.TestCase):
                 # we found a TestCase class, now scan it for test methods
                 for obj2 in vars(obj).values():
                     # inspect.ismethod doesn't seem to work here
@@ -387,7 +389,6 @@
         self.lastresults = {}
         for item in self.items:
             result = item.run()
-            print result.formatted_traceback
             key = classify(result)
             self.lastresults.setdefault(key, []).append(result)
             yield result
@@ -404,8 +405,7 @@
     # collect tests
     ts = TestSuite()
     print "Loading test modules ..."
-    ts.initfromdir(autopath.pypydir, filterfunc=filterfunc)
-    print "Loading test modules ..."
+    #ts.initfromdir(autopath.pypydir, filterfunc=filterfunc)
     ts.initfromdir('.', filterfunc=filterfunc)
     # iterate over tests and collect data
     for res in ts.testresults():


More information about the Pypy-commit mailing list