[py-svn] r36386 - in py/dist/py/test: . testing

hpk at codespeak.net hpk at codespeak.net
Tue Jan 9 19:16:32 CET 2007


Author: hpk
Date: Tue Jan  9 19:16:26 2007
New Revision: 36386

Modified:
   py/dist/py/test/collect.py
   py/dist/py/test/testing/test_collect.py
Log:
now the collection of generative tests follows
the setup/teardown procedures (setup_module and friends) 
which fixes a problem reported by Pierre Rouleau


Modified: py/dist/py/test/collect.py
==============================================================================
--- py/dist/py/test/collect.py	(original)
+++ py/dist/py/test/collect.py	Tue Jan  9 19:16:26 2007
@@ -206,9 +206,8 @@
     def tryiter(self, yieldtype=None, reporterror=None, keyword=None):
         """ yield stop item instances from flattening the collector. 
             XXX deprecated: this way of iteration is not safe in all
-            cases. Mostly fixed, need to introduce skipped-by-keyword
+            cases. 
         """ 
-        
         if yieldtype is None: 
             yieldtype = py.test.Item 
         if isinstance(self, yieldtype):
@@ -225,7 +224,8 @@
                     if reporterror is not None:
                         reporterror((None, self))
                     for x in self.run(): 
-                        for y in self.join(x).tryiter(yieldtype, reporterror, keyword): 
+                        for y in self.join(x).tryiter(yieldtype, 
+                                            reporterror, keyword): 
                             yield y
                 except KeyboardInterrupt:
                     raise
@@ -459,12 +459,14 @@
     
     def buildname2items(self): 
         d = {} 
+        # slightly hackish to invoke setup-states on
+        # collection ...
+        self.Function.state.prepare(self)
         for i, x in py.builtin.enumerate(self.obj()): 
             call, args = self.getcallargs(x)
             if not callable(call): 
                 raise TypeError("yielded test %r not callable" %(call,))
             name = "[%d]" % i
-            #XXX name = "%s(%r)" %(call.__name__, str(args and args[0] or i)) # # XXX
             d[name] = self.Function(name, self, args, obj=call, sort_value = i)
         return d
         

Modified: py/dist/py/test/testing/test_collect.py
==============================================================================
--- py/dist/py/test/testing/test_collect.py	(original)
+++ py/dist/py/test/testing/test_collect.py	Tue Jan  9 19:16:26 2007
@@ -366,7 +366,7 @@
     l = []
     list(col.tryiter(reporterror=l.append))
     assert len(l) == 2
-    excinfo, item = l[1]
+    excinfo, item = l[-1]
     assert isinstance(excinfo, py.code.ExceptionInfo)
 
 def test_tryiter_handles_keyboardinterrupt(): 
@@ -391,7 +391,6 @@
     assert col != fn
 
 def test_check_generator_collect_problems():
-    py.test.skip("Fails")
     tmp = py.test.ensuretemp("gener_coll")
     tmp.ensure("test_one.py").write(py.code.Source("""
         def setup_module(mod):
@@ -408,7 +407,7 @@
     col = py.test.collect.Module(tmp.join("test_one.py"))
     errors = []
     l = list(col.tryiter(reporterror=errors.append))
-    assert len(errors) == 0
+    assert len(errors) == 2
 
 def test_check_collect_hashes():
     tmp = py.test.ensuretemp("check_collect_hashes")


More information about the py-svn mailing list