[py-svn] r34534 - py/dist/py/test

fijal at codespeak.net fijal at codespeak.net
Sun Nov 12 21:24:16 CET 2006


Author: fijal
Date: Sun Nov 12 21:24:15 2006
New Revision: 34534

Modified:
   py/dist/py/test/collect.py
Log:
Add a bit of heuristic for collection order (it's better than it was before).


Modified: py/dist/py/test/collect.py
==============================================================================
--- py/dist/py/test/collect.py	(original)
+++ py/dist/py/test/collect.py	Sun Nov 12 21:24:15 2006
@@ -120,8 +120,8 @@
         return property(fget, fset, None, "underlying object") 
     obj = obj()
 
-    def _getobj(self): 
-        return getattr(self.parent.obj, self.name) 
+    def _getobj(self):
+        return getattr(self.parent.obj, self.name)
 
     def multijoin(self, namelist): 
         """ return a list of colitems for the given namelist. """ 
@@ -421,8 +421,16 @@
             teardown_class = getattr(teardown_class, 'im_func', teardown_class) 
             teardown_class(self.obj) 
 
-    def getsortvalue(self): 
-        for x in self.tryiter((py.test.collect.Generator, py.test.Item)): 
+    def getsortvalue(self):
+        try:
+            for key, val in self.obj.__dict__.iteritems():
+                import types
+                if type(val) is (types.FunctionType, types.GeneratorType):
+                    return val.func_code.co_firstlineno
+        except AttributeError:
+            pass
+        # fall back...
+        for x in self.tryiter((py.test.collect.Generator, py.test.Item)):
             return x.getsortvalue()
 
 class Instance(PyCollectorMixin, Collector): 


More information about the py-svn mailing list