[py-svn] r57140 - in py/branch/event/py/test2/rsession: . testing

hpk at codespeak.net hpk at codespeak.net
Sat Aug 9 17:12:45 CEST 2008


Author: hpk
Date: Sat Aug  9 17:12:44 2008
New Revision: 57140

Modified:
   py/branch/event/py/test2/rsession/async.py
   py/branch/event/py/test2/rsession/testing/test_async.py
Log:
exitfirst and more exitcodes


Modified: py/branch/event/py/test2/rsession/async.py
==============================================================================
--- py/branch/event/py/test2/rsession/async.py	(original)
+++ py/branch/event/py/test2/rsession/async.py	Sat Aug  9 17:12:44 2008
@@ -34,6 +34,7 @@
         self.queue = py.std.Queue.Queue()
         self.host2pending = {}
         self.hosts = []
+        self._testsfailed = False
 
     def fixoptions(self):
         """ check, fix and determine conflicting options. """
@@ -88,6 +89,8 @@
         except:
             self.bus.notify(repevent.InternalException())
             exitstatus = self.EXIT_INTERNALERROR
+        if exitstatus == 0 and self._testsfailed:
+            exitstatus = self.EXIT_TESTSFAILED
         return exitstatus
 
     def act_on_completed_tests(self):
@@ -114,8 +117,10 @@
         for host, pending in self.host2pending.items():
             if toremove is not None and toremove in pending:
                 pending.remove(toremove)
-                if ev.failed and self.config.option.exitfirst:
-                    break
+                if ev.failed:
+                    self._testsfailed = True
+                    if self.config.option.exitfirst:
+                        break
                 toremove = None
             if pending:
                 completed = False

Modified: py/branch/event/py/test2/rsession/testing/test_async.py
==============================================================================
--- py/branch/event/py/test2/rsession/testing/test_async.py	(original)
+++ py/branch/event/py/test2/rsession/testing/test_async.py	Sat Aug  9 17:12:44 2008
@@ -107,8 +107,7 @@
         dumpqueue(session.queue)
         assert exitstatus == session.EXIT_NOHOSTS
 
-    def test_exit_completed_tests(self):
-        item = self.getitem("def test_func(): pass")
+    def runthrough(self, item):
         session = AsyncSession(item._config)
         host1 = Host("localhost")
         host1.node = MockNode()
@@ -118,8 +117,18 @@
         session.queue.put(ev)
         exitstatus = session.loop([]) 
         dumpqueue(session.queue)
+        return session, exitstatus
+
+    def test_exit_completed_tests_ok(self):
+        item = self.getitem("def test_func(): pass")
+        session, exitstatus = self.runthrough(item)
         assert exitstatus == session.EXIT_OK
 
+    def test_exit_completed_tests_fail(self):
+        item = self.getitem("def test_func(): 0/0")
+        session, exitstatus = self.runthrough(item)
+        assert exitstatus == session.EXIT_TESTSFAILED
+
     def test_exit_on_first_failing(self):
         modcol = self.getmodulecol("""
             def test_fail(): 
@@ -141,4 +150,4 @@
         exitstatus = session.loop([]) 
         assert session.queue.qsize() == 1
         dumpqueue(session.queue)
-        #assert exitstatus == session.EXIT_TESTSFAILED
+        assert exitstatus == session.EXIT_TESTSFAILED



More information about the pytest-commit mailing list