patch is in attachment. Don't know if it's best way how to solve this
problem but it works and doesnt break any py.test tests :)

cu,
Maio

On 2/15/07, Marian Schubert <[EMAIL PROTECTED]> wrote:
Hello,

there are 2 files attachment. Both should be easly used to reproduce
bugs i found using py.test (which is great tool and i thank everyone
who created/contributed to it).

test_fail.py - both tests should fail because teardown_method is failing
test_output.py - there is output of teardown method of previous test
in current test's recorded output which i believe shouldn't be there


cu,
MS


Index: py/test/item.py
===================================================================
--- py/test/item.py	(revision 38996)
+++ py/test/item.py	(working copy)
@@ -13,7 +13,8 @@
     def teardown_all(self): 
         while self.stack: 
             col = self.stack.pop() 
-            col.teardown() 
+            if not isinstance(col, Function):
+                col.teardown() 
      
     def prepare(self, colitem): 
         """ setup objects along the collector chain to the test-method
@@ -24,7 +25,8 @@
             if self.stack == needed_collectors[:len(self.stack)]: 
                 break 
             col = self.stack.pop() 
-            col.teardown()
+            if not isinstance(col, Function):
+                col.teardown()
         for col in needed_collectors[len(self.stack):]: 
             #print "setting up", col
             col.setup() 
@@ -64,7 +66,10 @@
     def run(self):
         """ setup and execute the underlying test function. """
         self._state.prepare(self) 
-        self.execute(self.obj, *self._args)
+        try:
+            self.execute(self.obj, *self._args)
+        finally:
+            self.teardown()
 
     def execute(self, target, *args):
         """ execute the given test function. """
_______________________________________________
py-dev mailing list
py-dev@codespeak.net
http://codespeak.net/mailman/listinfo/py-dev

Reply via email to