[svn r63780] some renaming

--HG--
branch : trunk
This commit is contained in:
hpk 2009-04-07 11:53:01 +02:00
parent 4f5020c3dd
commit 5b31dfe357
6 changed files with 24 additions and 24 deletions

View File

@ -296,14 +296,14 @@ class TestDSession:
remaining = session.filteritems(items)
assert remaining == []
event = evrec.getevents("deselected")[-1]
event = evrec.getcalls("deselected")[-1]
assert event.items == items
modcol.config.option.keyword = "test_fail"
remaining = session.filteritems(items)
assert remaining == [items[0]]
event = evrec.getevents("deselected")[-1]
event = evrec.getcalls("deselected")[-1]
assert event.items == [items[1]]
def test_testnodedown_shutdown_after_completion(self, testdir):

View File

@ -111,7 +111,7 @@ class TestMasterSlaveConnection:
node = mysetup.makenode(item.config)
node.channel.close()
py.test.raises(IOError, "node.send(item)")
#ev = self.getevents("internalerror")
#ev = self.getcalls("internalerror")
#assert ev.excinfo.errisinstance(IOError)
def test_send_one(self, testdir, mysetup):

View File

@ -267,12 +267,12 @@ class Event:
def __repr__(self):
return "<Event %r %r>" %(self.name, self.args)
class ParsedEvent:
class ParsedCall:
def __init__(self, locals):
self.__dict__ = locals.copy()
def __repr__(self):
return "<ParsedEvent %r>" %(self.__dict__,)
return "<ParsedCall %r>" %(self.__dict__,)
class EventRecorder(object):
def __init__(self, pyplugins, debug=False): # True):
@ -288,17 +288,17 @@ class EventRecorder(object):
print "[event: %s]: %s **%s" %(name, ", ".join(map(str, args)), kwargs,)
self.events.append(Event(name, args, kwargs))
def popevent(self, name):
def popcall(self, name):
for i, event in py.builtin.enumerate(self.events):
if event.name == name:
del self.events[i]
eventparser = self.geteventparser(name)
eventparser = self._getcallparser(name)
return eventparser(*event.args, **event.kwargs)
raise KeyError("popevent: %r not found in %r" %(name, self.events))
def getevents(self, eventname):
""" return list of ParsedEvent instances matching the given eventname. """
method = self.geteventparser(eventname)
def getcalls(self, eventname):
""" return list of ParsedCall instances matching the given eventname. """
method = self._getcallparser(eventname)
l = []
for event in self.events:
if event.name == eventname:
@ -306,7 +306,7 @@ class EventRecorder(object):
l.append(pevent)
return l
def geteventparser(self, eventname):
def _getcallparser(self, eventname):
mname = "pyevent__" + eventname
method = getattr(api.Events, mname)
args, varargs, varkw, default = inspect.getargspec(method)
@ -314,7 +314,7 @@ class EventRecorder(object):
args = args[1:]
fspec = inspect.formatargspec(args, varargs, varkw, default)
code = py.code.compile("""def %(mname)s%(fspec)s:
return ParsedEvent(locals())""" % locals())
return ParsedCall(locals())""" % locals())
exec code
return locals()[mname]

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.getevents('deselected')) == 1
assert len(sorter.getcalls('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.getevents("deselected")
dlist = sorter.getcalls("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.getevents("deselected")
dlist = sorter.getcalls("deselected")
assert len(dlist) == 1
item = dlist[0].items[0]
assert item.name == "test_one"

View File

@ -26,7 +26,7 @@ class TestSetupState:
setup = SetupState()
res = setup.do_setup(item)
assert not res
rep = evrec.popevent("itemsetupreport").rep
rep = evrec.popcall("itemsetupreport").rep
assert rep.failed
assert not rep.skipped
assert rep.excrepr
@ -45,10 +45,10 @@ class TestSetupState:
setup = SetupState()
res = setup.do_setup(item)
assert res
rep = evrec.popevent("itemsetupreport").rep
rep = evrec.popcall("itemsetupreport").rep
assert rep.passed
setup.do_teardown(item)
rep = evrec.popevent("itemsetupreport").rep
rep = evrec.popcall("itemsetupreport").rep
assert rep.item == item
assert rep.failed
assert not rep.passed
@ -66,7 +66,7 @@ class TestSetupState:
evrec = testdir.geteventrecorder(item.config)
setup = SetupState()
setup.do_setup(item)
rep = evrec.popevent("itemsetupreport").rep
rep = evrec.popcall("itemsetupreport").rep
assert not rep.failed
assert rep.skipped
assert rep.excrepr
@ -77,7 +77,7 @@ class TestSetupState:
evrec = testdir.geteventrecorder(item.config)
setup = SetupState()
setup.do_fixture_and_runtest(item)
rep = evrec.popevent("itemtestreport").rep
rep = evrec.popcall("itemtestreport").rep
assert rep.passed
def test_runtest_fails(self, testdir):
@ -85,7 +85,7 @@ class TestSetupState:
evrec = testdir.geteventrecorder(item.config)
setup = SetupState()
setup.do_fixture_and_runtest(item)
event = evrec.popevent("item_runtest_finished")
event = evrec.popcall("item_runtest_finished")
assert event.excinfo

View File

@ -25,9 +25,9 @@ class SessionTests:
assert failed[0].colitem.name == "test_one_one"
assert failed[1].colitem.name == "test_other"
assert failed[2].colitem.name == "test_two"
itemstarted = sorter.getevents("itemstart")
itemstarted = sorter.getcalls("itemstart")
assert len(itemstarted) == 4
colstarted = sorter.getevents("collectionstart")
colstarted = sorter.getcalls("collectionstart")
assert len(colstarted) == 1
col = colstarted[0].collector
assert isinstance(col, py.test.collect.Module)
@ -202,7 +202,7 @@ class TestNewSession(SessionTests):
itemstarted = sorter.getnamed("itemstart")
assert len(itemstarted) == 3
assert not sorter.getnamed("itemtestreport")
started = sorter.getevents("collectionstart")
started = sorter.getcalls("collectionstart")
finished = sorter.getnamed("collectionreport")
assert len(started) == len(finished)
assert len(started) == 8