[py-svn] r51671 - in py/branch/event/py/test2: . rsession
hpk at codespeak.net
hpk at codespeak.net
Wed Feb 20 10:15:38 CET 2008
Author: hpk
Date: Wed Feb 20 10:15:37 2008
New Revision: 51671
Modified:
py/branch/event/py/test2/executor.py
py/branch/event/py/test2/item.py
py/branch/event/py/test2/rsession/slave.py
Log:
kill now redundant code, have dist and non-dist testing share some methods
Modified: py/branch/event/py/test2/executor.py
==============================================================================
--- py/branch/event/py/test2/executor.py (original)
+++ py/branch/event/py/test2/executor.py Wed Feb 20 10:15:37 2008
@@ -18,6 +18,11 @@
self.item = item
self.config = config
+ def setup_and_run(self):
+ testrep = self.execute()
+ self.config.bus.notify(testrep)
+ return testrep
+
def run(self, capture=True):
if capture:
self.item.startcapture()
@@ -119,3 +124,9 @@
finally:
self.item.execute = orig_exec
+def getexecutor(item, config):
+ cls = RunExecutor
+ if config.option.boxed:
+ cls = BoxExecutor
+ return cls(item, config)
+
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:15:37 2008
@@ -31,14 +31,10 @@
class Item(Base):
def runtest(self):
- from py.__.test2.executor import RunExecutor, BoxExecutor
- cls = RunExecutor
- if self._config.option.boxed:
- cls = BoxExecutor
- executor = cls(self, self._config)
- testrep = executor.execute()
- self._config.bus.notify(testrep)
-
+ from py.__.test2.executor import getexecutor
+ executor = getexecutor(self, self._config)
+ return executor.setup_and_run()
+
def startcapture(self):
self._config._startcapture(self, path=self.fspath)
Modified: py/branch/event/py/test2/rsession/slave.py
==============================================================================
--- py/branch/event/py/test2/rsession/slave.py (original)
+++ py/branch/event/py/test2/rsession/slave.py Wed Feb 20 10:15:37 2008
@@ -7,31 +7,15 @@
from py.__.test2 import repevent
import os
-def slave_main(receive, send, path, config):
- import os
- assert os.path.exists(path)
- path = os.path.abspath(path)
- if config.option.boxed:
- Executor = BoxExecutor
- else:
- Executor = RunExecutor
-
+def slave_main(receive, send, config):
while 1:
itemspec = receive()
if itemspec is None:
send(None)
break
- try:
- item = config._getcollector(itemspec)
- ex = Executor(item, config)
- res = ex.execute()
- except: # XXX consider bare except here
- excinfo = py.code.ExceptionInfo()
- # XXX excinfo
- res = repevent.ItemTestReport(itemspec)
- res.failed = True
- res.excinfo = str(excinfo)
- send(res.dumps())
+ item = config._getcollector(itemspec)
+ testrep = item.runtest()
+ send(testrep.dumps())
def setup():
# our current dir is the topdir
@@ -59,7 +43,7 @@
msg = channel.receive()
#print >>debug, "reveived", msg
return msg
- slave_main(receive, send, basedir, config)
+ slave_main(receive, send, config)
if not config.option.nomagic:
py.magic.revoke(assertion=1)
channel.close()
More information about the pytest-commit
mailing list