[svn r63571] kill another few test "events"

--HG--
branch : trunk
This commit is contained in:
hpk 2009-04-03 17:47:16 +02:00
parent 45e0499f10
commit 53491b1531
8 changed files with 27 additions and 64 deletions

View File

@ -45,8 +45,8 @@ class LoopState(object):
self.dsession.handle_crashitem(crashitem, node)
self.colitems.extend(pending[1:])
def pyevent__rescheduleitems(self, event):
self.colitems.extend(event.items)
def pyevent__rescheduleitems(self, items):
self.colitems.extend(items)
self.dowork = False # avoid busywait
class DSession(Session):
@ -175,7 +175,7 @@ class DSession(Session):
if isinstance(next, py.test.collect.Item):
senditems.append(next)
else:
self.bus.notify("collectionstart", event.CollectionStart(next))
self.bus.notify("collectionstart", next)
self.queueevent("collectionreport", basic_collect_report(next))
if self.config.option.dist == "each":
self.senditems_each(senditems)
@ -202,7 +202,7 @@ class DSession(Session):
tosend[:] = tosend[room:] # update inplace
if tosend:
# we have some left, give it to the main loop
self.queueevent("rescheduleitems", event.RescheduleItems(tosend))
self.queueevent("rescheduleitems", tosend)
def senditems_load(self, tosend):
if not tosend:
@ -224,7 +224,7 @@ class DSession(Session):
break
if tosend:
# we have some left, give it to the main loop
self.queueevent("rescheduleitems", event.RescheduleItems(tosend))
self.queueevent("rescheduleitems", tosend)
def removeitem(self, item, node):
if item not in self.item2nodes:

View File

@ -101,8 +101,8 @@ class TestDSession:
assert session.node2pending[node2] == sent2
name, args, kwargs = session.queue.get(block=False)
assert name == "rescheduleitems"
ev, = args
assert ev.items == [item]
items, = args
assert items == [item]
def test_keyboardinterrupt(self, testdir):
item = testdir.getitem("def test_func(): pass")
@ -125,9 +125,8 @@ class TestDSession:
session = DSession(item.config)
node = MockNode()
session.addnode(node)
ev = event.RescheduleItems([item])
loopstate = session._initloopstate([])
session.queueevent("rescheduleitems", ev)
session.queueevent("rescheduleitems", [item])
session.loop_once(loopstate)
# check that RescheduleEvents are not immediately
# rescheduled if there are no nodes
@ -298,17 +297,15 @@ class TestDSession:
remaining = session.filteritems(items)
assert remaining == []
event = evrec.events[-1]
assert event.name == "deselected"
assert event.args[0].items == items
event = evrec.getevents("deselected")[-1]
assert event.items == items
modcol.config.option.keyword = "test_fail"
remaining = session.filteritems(items)
assert remaining == [items[0]]
event = evrec.events[-1]
assert event.name == "deselected"
assert event.args[0].items == [items[1]]
event = evrec.getevents("deselected")[-1]
assert event.items == [items[1]]
def test_testnodedown_shutdown_after_completion(self, testdir):
item = testdir.getitem("def test_func(): pass")

View File

@ -12,9 +12,6 @@ class BaseEvent(object):
for key, value in self.__dict__.items()]
return "<%s %s>" %(self.__class__.__name__, " ".join(l),)
def timestamp():
return time.time()
class NOP(BaseEvent):
pass
@ -22,10 +19,6 @@ class NOP(BaseEvent):
# Events related to collecting and executing test Items
# ----------------------------------------------------------------------
class Deselected(BaseEvent):
def __init__(self, items):
self.items = items
class BaseReport(BaseEvent):
def toterminal(self, out):
longrepr = self.longrepr
@ -73,9 +66,6 @@ class ItemTestReport(BaseReport):
self.shortrepr = shortrepr
self.longrepr = longrepr
class CollectionStart(BaseEvent):
def __init__(self, collector):
self.collector = collector
class CollectionReport(BaseReport):
""" Collection Report. """
@ -108,30 +98,6 @@ class LooponfailingInfo(BaseEvent):
self.failreports = failreports
self.rootdirs = rootdirs
# ----------------------------------------------------------------------
# Distributed Testing Events
# ----------------------------------------------------------------------
class RescheduleItems(BaseEvent):
def __init__(self, items):
self.items = items
# ---------------------------------------------------------------------
# Events related to rsyncing
# ---------------------------------------------------------------------
class HostRSyncing(BaseEvent):
def __init__(self, host, root, remotepath, synced):
self.host = host
self.root = root
self.remotepath = remotepath
self.synced = synced
class HostRSyncRootReady(BaseEvent):
def __init__(self, host, root):
self.host = host
self.root = root
# make all eventclasses available on BaseEvent so that
# consumers of events can easily filter by
# 'isinstance(event, event.Name)' checks

View File

@ -82,10 +82,10 @@ class Events:
def pyevent__itemtestreport(self, event):
""" test has been run. """
def pyevent__deselected(self, event):
""" item has been dselected. """
def pyevent__deselected(self, items):
""" collected items that were deselected (by keyword). """
def pyevent__collectionstart(self, event):
def pyevent__collectionstart(self, collector):
""" collector starts collecting. """
def pyevent__collectionreport(self, event):

View File

@ -158,8 +158,8 @@ class TerminalReporter:
if self.config.option.debug:
self.write_sep("!", "RESCHEDULING %s " %(event.items,))
def pyevent__deselected(self, event):
self.stats.setdefault('deselected', []).append(event)
def pyevent__deselected(self, items):
self.stats.setdefault('deselected', []).append(items)
def pyevent__itemtestreport(self, event):
fspath = event.colitem.fspath
@ -309,8 +309,8 @@ class CollectonlyReporter:
def outindent(self, line):
self.out.line(self.indent + str(line))
def pyevent__collectionstart(self, event):
self.outindent(event.collector)
def pyevent__collectionstart(self, collector):
self.outindent(collector)
self.indent += self.INDENT
def pyevent__itemstart(self, item, node=None):
@ -627,7 +627,7 @@ class TestCollectonly:
rep = CollectonlyReporter(modcol.config, out=linecomp.stringio)
modcol.config.bus.register(rep)
indent = rep.indent
rep.config.bus.notify("collectionstart", event.CollectionStart(modcol))
rep.config.bus.notify("collectionstart", modcol)
linecomp.assert_contains_lines([
"<Module 'test_collectonly_basic.py'>"
])

View File

@ -42,7 +42,7 @@ class Session(object):
yield next
else:
assert isinstance(next, Collector)
notify("collectionstart", event.CollectionStart(next))
notify("collectionstart", next)
ev = basic_collect_report(next)
if ev.passed:
for x in self.genitems(ev.result, keywordexpr):
@ -67,7 +67,7 @@ class Session(object):
continue
remaining.append(colitem)
if deselected:
self.bus.notify("deselected", event.Deselected(deselected, ))
self.bus.notify("deselected", deselected)
if self.config.option.keyword.endswith(":"):
self._nomatch = True
return remaining

View File

@ -74,7 +74,7 @@ class TestKeywordSelection:
passed, skipped, failed = sorter.listoutcomes()
assert len(failed) == 1
assert failed[0].colitem.name == name
assert len(sorter.getnamed('deselected')) == 1
assert len(sorter.getevents('deselected')) == 1
for keyword in ['test_one', 'est_on']:
#yield check, keyword, 'test_one'
@ -102,7 +102,7 @@ class TestKeywordSelection:
passed, skipped, failed = sorter.listoutcomes()
assert len(passed) == 1
assert passed[0].colitem.name == "test_2"
dlist = sorter.getnamed("deselected")
dlist = sorter.getevents("deselected")
assert len(dlist) == 1
assert dlist[0].items[0].name == 'test_1'
@ -116,7 +116,7 @@ class TestKeywordSelection:
passed, skipped, failed = sorter.listoutcomes()
assert len(passed) == 2
assert not failed
dlist = sorter.getnamed("deselected")
dlist = sorter.getevents("deselected")
assert len(dlist) == 1
item = dlist[0].items[0]
assert item.name == "test_one"

View File

@ -29,7 +29,7 @@ class SessionTests:
assert len(itemstarted) == 4
colstarted = sorter.getevents("collectionstart")
assert len(colstarted) == 1
col = colstarted[0].event.collector
col = colstarted[0].collector
assert isinstance(col, py.test.collect.Module)
def test_nested_import_error(self, testdir):
@ -204,7 +204,7 @@ class TestNewSession(SessionTests):
itemstarted = sorter.getnamed("itemstart")
assert len(itemstarted) == 3
assert not sorter.getnamed("itemtestreport")
started = sorter.getnamed("collectionstart")
started = sorter.getevents("collectionstart")
finished = sorter.getnamed("collectionreport")
assert len(started) == len(finished)
assert len(started) == 8