[py-svn] r46009 - in py/branch/session-cleanups/py/test: . rsession testing

fijal at codespeak.net fijal at codespeak.net
Mon Aug 27 10:41:57 CEST 2007


Author: fijal
Date: Mon Aug 27 10:41:57 2007
New Revision: 46009

Modified:
   py/branch/session-cleanups/py/test/rsession/rsession.py
   py/branch/session-cleanups/py/test/session.py
   py/branch/session-cleanups/py/test/testing/test_reporter.py
Log:
A bit more shuffling stuff around


Modified: py/branch/session-cleanups/py/test/rsession/rsession.py
==============================================================================
--- py/branch/session-cleanups/py/test/rsession/rsession.py	(original)
+++ py/branch/session-cleanups/py/test/rsession/rsession.py	Mon Aug 27 10:41:57 2007
@@ -14,31 +14,8 @@
 from py.__.test.rsession.local import local_loop, plain_runner, apigen_runner,\
     box_runner
 from py.__.test.reporter import LocalReporter, RemoteReporter, TestReporter
-from py.__.test.session import Session
+from py.__.test.session import AbstractSession
 from py.__.test.outcome import Skipped, Failed
-
-class AbstractSession(Session): 
-    """
-        An abstract session executes collectors/items through a runner. 
-
-    """
-    def fixoptions(self):
-        option = self.config.option 
-        if option.runbrowser and not option.startserver:
-            #print "--runbrowser implies --startserver"
-            option.startserver = True
-        if self.config.getvalue("dist_boxed"):
-            option.boxed = True
-        super(AbstractSession, self).fixoptions()
-
-    def init_reporter(self, reporter, config, hosts):
-        if reporter is None:
-            reporter = choose_reporter(config)(config, hm.hosts)
-        else:
-            reporter = TestReporter(reporter)
-        checkfun = lambda : self.config.option.exitfirst and \
-                            reporter.was_failure()
-        return reporter, checkfun
     
 class RSession(AbstractSession):
     """ Remote version of session

Modified: py/branch/session-cleanups/py/test/session.py
==============================================================================
--- py/branch/session-cleanups/py/test/session.py	(original)
+++ py/branch/session-cleanups/py/test/session.py	Mon Aug 27 10:41:57 2007
@@ -1,33 +1,23 @@
 import py
 from py.__.test.outcome import Outcome, Failed, Passed, Skipped
+from py.__.test.reporter import choose_reporter, TestReporter
 
-class Session(object):
-    """
-        A Session gets test Items from Collectors, # executes the
-        Items and sends the Outcome to the Reporter.
+class AbstractSession(object): 
+    """ An abstract session executes collectors/items through a runner. 
     """
     def __init__(self, config): 
         self._memo = []
         self.config = config
         self._keyword = config.option.keyword
 
-    def shouldclose(self): 
-        return False 
-
-    def header(self, colitems):
-        """ setup any neccessary resources ahead of the test run. """
-        if not self.config.option.nomagic:
-            py.magic.invoke(assertion=1)
-
-    def footer(self, colitems):
-        """ teardown any resources after a test run. """ 
-        py.test.collect.Function._state.teardown_all()
-        if not self.config.option.nomagic:
-            py.magic.revoke(assertion=1)
-
     def fixoptions(self):
         """ check, fix and determine conflicting options. """
-        option = self.config.option
+        option = self.config.option 
+        if option.runbrowser and not option.startserver:
+            #print "--runbrowser implies --startserver"
+            option.startserver = True
+        if self.config.getvalue("dist_boxed") and option.dist:
+            option.boxed = True
         # implied options
         if option.usepdb:
             if not option.nocapture:
@@ -43,6 +33,34 @@
         if option.keyword_oneshot and not option.keyword:
             raise ValueError, "--keyword-oneshot makes sense only when --keyword is supplied"
 
+    def init_reporter(self, reporter, config, hosts):
+        if reporter is None:
+            reporter = choose_reporter(config)(config, hosts)
+        else:
+            reporter = TestReporter(reporter)
+        checkfun = lambda : self.config.option.exitfirst and \
+                            reporter.was_failure()
+        return reporter, checkfun
+
+class Session(AbstractSession):
+    """
+        A Session gets test Items from Collectors, # executes the
+        Items and sends the Outcome to the Reporter.
+    """
+    def shouldclose(self): 
+        return False
+
+    def header(self, colitems):
+        """ setup any neccessary resources ahead of the test run. """
+        if not self.config.option.nomagic:
+            py.magic.invoke(assertion=1)
+
+    def footer(self, colitems):
+        """ teardown any resources after a test run. """ 
+        py.test.collect.Function._state.teardown_all()
+        if not self.config.option.nomagic:
+            py.magic.revoke(assertion=1)
+
     def start(self, colitem): 
         """ hook invoked before each colitem.run() invocation. """ 
 

Modified: py/branch/session-cleanups/py/test/testing/test_reporter.py
==============================================================================
--- py/branch/session-cleanups/py/test/testing/test_reporter.py	(original)
+++ py/branch/session-cleanups/py/test/testing/test_reporter.py	Mon Aug 27 10:41:57 2007
@@ -18,7 +18,7 @@
 
 
 import py, os
-from py.__.test.rsession.rsession import AbstractSession
+from py.__.test.session import AbstractSession
 from py.__.test.reporter import RemoteReporter, LocalReporter, choose_reporter 
 from py.__.test import repevent
 from py.__.test.outcome import ReprOutcome, SerializableOutcome


More information about the py-svn mailing list