[py-svn] r61950 - py/branch/pytestplugin/py/test
hpk at codespeak.net
hpk at codespeak.net
Mon Feb 16 15:01:56 CET 2009
Author: hpk
Date: Mon Feb 16 15:01:54 2009
New Revision: 61950
Modified:
py/branch/pytestplugin/py/test/config.py
py/branch/pytestplugin/py/test/event.py
py/branch/pytestplugin/py/test/session.py
Log:
intermediate prepare move to kw events
Modified: py/branch/pytestplugin/py/test/config.py
==============================================================================
--- py/branch/pytestplugin/py/test/config.py (original)
+++ py/branch/pytestplugin/py/test/config.py Mon Feb 16 15:01:54 2009
@@ -4,6 +4,7 @@
from conftesthandle import Conftest
from py.__.test.defaultconftest import adddefaultoptions
from py.__.test.pmanage import PluginManager
+from py.__.test.event import EventBus
optparse = py.compat.optparse
@@ -34,8 +35,9 @@
self.option = CmdOptions()
self._parser = optparse.OptionParser(
usage="usage: %prog [options] [query] [filenames of tests]")
- from py.__.test.event import EventBus
- self.bus = EventBus(bus)
+ if bus is None:
+ bus = EventBus()
+ self.bus = bus
self.pluginmanager = PluginManager()
self._conftest = Conftest(onimport=self.pluginmanager.consider_module)
@@ -254,7 +256,7 @@
pass
# this is the one per-process instance of py.test configuration
-config_per_process = Config(bus=py.event)
+config_per_process = Config(bus=EventBus(bus=py.event))
# default import paths for sessions
Modified: py/branch/pytestplugin/py/test/event.py
==============================================================================
--- py/branch/pytestplugin/py/test/event.py (original)
+++ py/branch/pytestplugin/py/test/event.py Mon Feb 16 15:01:54 2009
@@ -41,9 +41,11 @@
else:
self._bus.unsubscribe(**kw)
- def notify(self, event):
- self._bus.notify(anonymous=event)
-
+ def notify(self, event=None, **kw):
+ if event is not None:
+ kw = kw.copy()
+ kw['*'] = event
+ self._bus.notify(**kw)
class BaseEvent(object):
def __repr__(self):
Modified: py/branch/pytestplugin/py/test/session.py
==============================================================================
--- py/branch/pytestplugin/py/test/session.py (original)
+++ py/branch/pytestplugin/py/test/session.py Mon Feb 16 15:01:54 2009
@@ -45,16 +45,16 @@
if isinstance(next, Item):
remaining = self.filteritems([next])
if remaining:
- self.bus.notify(event.ItemStart(next))
+ self.bus.notify(itemstart=event.ItemStart(next))
yield next
else:
assert isinstance(next, Collector)
- self.bus.notify(event.CollectionStart(next))
+ self.bus.notify(collectionstart=event.CollectionStart(next))
ev = basic_collect_report(next)
if ev.passed:
for x in self.genitems(ev.result, keywordexpr):
yield x
- self.bus.notify(ev)
+ self.bus.notify(collectionfinish=ev)
def filteritems(self, colitems):
""" return items to process (some may be deselected)"""
@@ -72,7 +72,7 @@
continue
remaining.append(colitem)
if deselected:
- self.bus.notify(event.Deselected(deselected, ))
+ self.bus.notify(deselectedtest=event.Deselected(deselected, ))
if self.config.option.keyword.endswith(":"):
self._nomatch = True
return remaining
@@ -84,7 +84,7 @@
def sessionstarts(self):
""" setup any neccessary resources ahead of the test run. """
- self.bus.notify(event.TestrunStart())
+ self.bus.notify(sessionstarts=event.TestrunStart())
# XXX the following is not used or neccessary for the DSession subclass
self._failurelist = []
self.bus.subscribe(self._processfailures)
@@ -97,7 +97,7 @@
def sessionfinishes(self, exitstatus=0, excinfo=None):
""" teardown any resources after a test run. """
- self.bus.notify(event.TestrunFinish(exitstatus=exitstatus,
+ self.bus.notify(sessionfinishes=event.TestrunFinish(exitstatus=exitstatus,
excinfo=excinfo))
self.bus.unsubscribe(self._processfailures)
return self._failurelist
@@ -113,7 +113,7 @@
colitems = self.getinitialitems(colitems)
self.shouldstop = False
self.sessionstarts()
- self.bus.notify(makehostup())
+ self.bus.notify(hostup=makehostup())
exitstatus = outcome.EXIT_OK
captured_excinfo = None
try:
@@ -127,7 +127,7 @@
captured_excinfo = py.code.ExceptionInfo()
exitstatus = outcome.EXIT_INTERRUPTED
except:
- self.bus.notify(event.InternalException())
+ self.bus.notify(internalerror=event.InternalException())
exitstatus = outcome.EXIT_INTERNALERROR
if self._failurelist and exitstatus == 0:
exitstatus = outcome.EXIT_TESTSFAILED
@@ -141,5 +141,4 @@
runner = item._getrunner()
pdb = self.config.option.usepdb and self.runpdb or None
testrep = runner(item, pdb=pdb)
- self.bus.notify(testrep)
-
+ self.bus.notify(itemtestreport=testrep)
More information about the pytest-commit
mailing list