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

hpk at codespeak.net hpk at codespeak.net
Wed Feb 20 10:31:22 CET 2008


Author: hpk
Date: Wed Feb 20 10:31:22 2008
New Revision: 51674

Modified:
   py/branch/event/py/test2/collect.py
   py/branch/event/py/test2/config.py
   py/branch/event/py/test2/item.py
   py/branch/event/py/test2/session.py
   py/branch/event/py/test2/testing/test_collect.py
Log:
another global bites the dust - put function
setupstate into config object now that the 
latter is uniformly available. 


Modified: py/branch/event/py/test2/collect.py
==============================================================================
--- py/branch/event/py/test2/collect.py	(original)
+++ py/branch/event/py/test2/collect.py	Wed Feb 20 10:31:22 2008
@@ -473,9 +473,9 @@
     
     def _buildname2items(self): 
         d = {} 
-        # slightly hackish to invoke setup-states on
-        # collection ...
-        self.Function._state.prepare(self)
+        # test generators participate in 
+        # the setup and teardown protocol 
+        self._config._setupstate.prepare(self)
         for i, x in py.builtin.enumerate(self.obj()): 
             call, args = self.getcallargs(x)
             if not callable(call): 

Modified: py/branch/event/py/test2/config.py
==============================================================================
--- py/branch/event/py/test2/config.py	(original)
+++ py/branch/event/py/test2/config.py	Wed Feb 20 10:31:22 2008
@@ -4,6 +4,7 @@
 from conftesthandle import Conftest
 from py.__.test2.defaultconftest import adddefaultoptions
 from py.__.test2.eventbus import EventBus
+from py.__.test2.item import SetupState
 
 optparse = py.compat.optparse
 
@@ -36,6 +37,7 @@
         self._conftest = Conftest()
         self._initialized = False
         self.bus = EventBus()
+        self._setupstate = SetupState()
 
     def parse(self, args): 
         """ parse cmdline arguments into this config object. 

Modified: py/branch/event/py/test2/item.py
==============================================================================
--- py/branch/event/py/test2/item.py	(original)
+++ py/branch/event/py/test2/item.py	Wed Feb 20 10:31:22 2008
@@ -45,7 +45,6 @@
     """ a Function Item is responsible for setting up  
         and executing a Python callable test object.
     """
-    _state = SetupState()
     def __init__(self, name, parent, args=(), callobj=_dummy):
         super(Function, self).__init__(name, parent) 
         self._args = args
@@ -54,7 +53,7 @@
 
     def run(self):
         """ setup and execute the underlying test function. """
-        self._state.prepare(self) 
+        self._config._setupstate.prepare(self) 
         self.execute(self.obj, *self._args)
 
     def execute(self, target, *args):

Modified: py/branch/event/py/test2/session.py
==============================================================================
--- py/branch/event/py/test2/session.py	(original)
+++ py/branch/event/py/test2/session.py	Wed Feb 20 10:31:22 2008
@@ -49,7 +49,7 @@
 
     def teardown(self):
         """ teardown any resources after a test run. """ 
-        py.test2.collect.Function._state.teardown_all()
+        self.config._setupstate.teardown_all()
         if not self.config.option.nomagic:
             py.magic.revoke(assertion=1)
         return self._failurelist 

Modified: py/branch/event/py/test2/testing/test_collect.py
==============================================================================
--- py/branch/event/py/test2/testing/test_collect.py	(original)
+++ py/branch/event/py/test2/testing/test_collect.py	Wed Feb 20 10:31:22 2008
@@ -5,10 +5,12 @@
 from py.__.test2.doctest import DoctestText
 import setupdata, suptest
 from py.__.test2.conftesthandle import Conftest
+from py.__.test2.item import SetupState
 
 class DummyConfig:
     def __init__(self):
         self._conftest = Conftest()
+        self._setupstate = SetupState()
     def getvalue(self, name, fspath):
         return self._conftest.rget(name, fspath)
 


More information about the py-svn mailing list