parent
4f5020c3dd
commit
5b31dfe357
|
@ -296,14 +296,14 @@ class TestDSession:
|
||||||
remaining = session.filteritems(items)
|
remaining = session.filteritems(items)
|
||||||
assert remaining == []
|
assert remaining == []
|
||||||
|
|
||||||
event = evrec.getevents("deselected")[-1]
|
event = evrec.getcalls("deselected")[-1]
|
||||||
assert event.items == items
|
assert event.items == items
|
||||||
|
|
||||||
modcol.config.option.keyword = "test_fail"
|
modcol.config.option.keyword = "test_fail"
|
||||||
remaining = session.filteritems(items)
|
remaining = session.filteritems(items)
|
||||||
assert remaining == [items[0]]
|
assert remaining == [items[0]]
|
||||||
|
|
||||||
event = evrec.getevents("deselected")[-1]
|
event = evrec.getcalls("deselected")[-1]
|
||||||
assert event.items == [items[1]]
|
assert event.items == [items[1]]
|
||||||
|
|
||||||
def test_testnodedown_shutdown_after_completion(self, testdir):
|
def test_testnodedown_shutdown_after_completion(self, testdir):
|
||||||
|
|
|
@ -111,7 +111,7 @@ class TestMasterSlaveConnection:
|
||||||
node = mysetup.makenode(item.config)
|
node = mysetup.makenode(item.config)
|
||||||
node.channel.close()
|
node.channel.close()
|
||||||
py.test.raises(IOError, "node.send(item)")
|
py.test.raises(IOError, "node.send(item)")
|
||||||
#ev = self.getevents("internalerror")
|
#ev = self.getcalls("internalerror")
|
||||||
#assert ev.excinfo.errisinstance(IOError)
|
#assert ev.excinfo.errisinstance(IOError)
|
||||||
|
|
||||||
def test_send_one(self, testdir, mysetup):
|
def test_send_one(self, testdir, mysetup):
|
||||||
|
|
|
@ -267,12 +267,12 @@ class Event:
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<Event %r %r>" %(self.name, self.args)
|
return "<Event %r %r>" %(self.name, self.args)
|
||||||
|
|
||||||
class ParsedEvent:
|
class ParsedCall:
|
||||||
def __init__(self, locals):
|
def __init__(self, locals):
|
||||||
self.__dict__ = locals.copy()
|
self.__dict__ = locals.copy()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<ParsedEvent %r>" %(self.__dict__,)
|
return "<ParsedCall %r>" %(self.__dict__,)
|
||||||
|
|
||||||
class EventRecorder(object):
|
class EventRecorder(object):
|
||||||
def __init__(self, pyplugins, debug=False): # True):
|
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,)
|
print "[event: %s]: %s **%s" %(name, ", ".join(map(str, args)), kwargs,)
|
||||||
self.events.append(Event(name, 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):
|
for i, event in py.builtin.enumerate(self.events):
|
||||||
if event.name == name:
|
if event.name == name:
|
||||||
del self.events[i]
|
del self.events[i]
|
||||||
eventparser = self.geteventparser(name)
|
eventparser = self._getcallparser(name)
|
||||||
return eventparser(*event.args, **event.kwargs)
|
return eventparser(*event.args, **event.kwargs)
|
||||||
raise KeyError("popevent: %r not found in %r" %(name, self.events))
|
raise KeyError("popevent: %r not found in %r" %(name, self.events))
|
||||||
|
|
||||||
def getevents(self, eventname):
|
def getcalls(self, eventname):
|
||||||
""" return list of ParsedEvent instances matching the given eventname. """
|
""" return list of ParsedCall instances matching the given eventname. """
|
||||||
method = self.geteventparser(eventname)
|
method = self._getcallparser(eventname)
|
||||||
l = []
|
l = []
|
||||||
for event in self.events:
|
for event in self.events:
|
||||||
if event.name == eventname:
|
if event.name == eventname:
|
||||||
|
@ -306,7 +306,7 @@ class EventRecorder(object):
|
||||||
l.append(pevent)
|
l.append(pevent)
|
||||||
return l
|
return l
|
||||||
|
|
||||||
def geteventparser(self, eventname):
|
def _getcallparser(self, eventname):
|
||||||
mname = "pyevent__" + eventname
|
mname = "pyevent__" + eventname
|
||||||
method = getattr(api.Events, mname)
|
method = getattr(api.Events, mname)
|
||||||
args, varargs, varkw, default = inspect.getargspec(method)
|
args, varargs, varkw, default = inspect.getargspec(method)
|
||||||
|
@ -314,7 +314,7 @@ class EventRecorder(object):
|
||||||
args = args[1:]
|
args = args[1:]
|
||||||
fspec = inspect.formatargspec(args, varargs, varkw, default)
|
fspec = inspect.formatargspec(args, varargs, varkw, default)
|
||||||
code = py.code.compile("""def %(mname)s%(fspec)s:
|
code = py.code.compile("""def %(mname)s%(fspec)s:
|
||||||
return ParsedEvent(locals())""" % locals())
|
return ParsedCall(locals())""" % locals())
|
||||||
exec code
|
exec code
|
||||||
return locals()[mname]
|
return locals()[mname]
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ class TestKeywordSelection:
|
||||||
passed, skipped, failed = sorter.listoutcomes()
|
passed, skipped, failed = sorter.listoutcomes()
|
||||||
assert len(failed) == 1
|
assert len(failed) == 1
|
||||||
assert failed[0].colitem.name == name
|
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']:
|
for keyword in ['test_one', 'est_on']:
|
||||||
#yield check, keyword, 'test_one'
|
#yield check, keyword, 'test_one'
|
||||||
|
@ -102,7 +102,7 @@ class TestKeywordSelection:
|
||||||
passed, skipped, failed = sorter.listoutcomes()
|
passed, skipped, failed = sorter.listoutcomes()
|
||||||
assert len(passed) == 1
|
assert len(passed) == 1
|
||||||
assert passed[0].colitem.name == "test_2"
|
assert passed[0].colitem.name == "test_2"
|
||||||
dlist = sorter.getevents("deselected")
|
dlist = sorter.getcalls("deselected")
|
||||||
assert len(dlist) == 1
|
assert len(dlist) == 1
|
||||||
assert dlist[0].items[0].name == 'test_1'
|
assert dlist[0].items[0].name == 'test_1'
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ class TestKeywordSelection:
|
||||||
passed, skipped, failed = sorter.listoutcomes()
|
passed, skipped, failed = sorter.listoutcomes()
|
||||||
assert len(passed) == 2
|
assert len(passed) == 2
|
||||||
assert not failed
|
assert not failed
|
||||||
dlist = sorter.getevents("deselected")
|
dlist = sorter.getcalls("deselected")
|
||||||
assert len(dlist) == 1
|
assert len(dlist) == 1
|
||||||
item = dlist[0].items[0]
|
item = dlist[0].items[0]
|
||||||
assert item.name == "test_one"
|
assert item.name == "test_one"
|
||||||
|
|
|
@ -26,7 +26,7 @@ class TestSetupState:
|
||||||
setup = SetupState()
|
setup = SetupState()
|
||||||
res = setup.do_setup(item)
|
res = setup.do_setup(item)
|
||||||
assert not res
|
assert not res
|
||||||
rep = evrec.popevent("itemsetupreport").rep
|
rep = evrec.popcall("itemsetupreport").rep
|
||||||
assert rep.failed
|
assert rep.failed
|
||||||
assert not rep.skipped
|
assert not rep.skipped
|
||||||
assert rep.excrepr
|
assert rep.excrepr
|
||||||
|
@ -45,10 +45,10 @@ class TestSetupState:
|
||||||
setup = SetupState()
|
setup = SetupState()
|
||||||
res = setup.do_setup(item)
|
res = setup.do_setup(item)
|
||||||
assert res
|
assert res
|
||||||
rep = evrec.popevent("itemsetupreport").rep
|
rep = evrec.popcall("itemsetupreport").rep
|
||||||
assert rep.passed
|
assert rep.passed
|
||||||
setup.do_teardown(item)
|
setup.do_teardown(item)
|
||||||
rep = evrec.popevent("itemsetupreport").rep
|
rep = evrec.popcall("itemsetupreport").rep
|
||||||
assert rep.item == item
|
assert rep.item == item
|
||||||
assert rep.failed
|
assert rep.failed
|
||||||
assert not rep.passed
|
assert not rep.passed
|
||||||
|
@ -66,7 +66,7 @@ class TestSetupState:
|
||||||
evrec = testdir.geteventrecorder(item.config)
|
evrec = testdir.geteventrecorder(item.config)
|
||||||
setup = SetupState()
|
setup = SetupState()
|
||||||
setup.do_setup(item)
|
setup.do_setup(item)
|
||||||
rep = evrec.popevent("itemsetupreport").rep
|
rep = evrec.popcall("itemsetupreport").rep
|
||||||
assert not rep.failed
|
assert not rep.failed
|
||||||
assert rep.skipped
|
assert rep.skipped
|
||||||
assert rep.excrepr
|
assert rep.excrepr
|
||||||
|
@ -77,7 +77,7 @@ class TestSetupState:
|
||||||
evrec = testdir.geteventrecorder(item.config)
|
evrec = testdir.geteventrecorder(item.config)
|
||||||
setup = SetupState()
|
setup = SetupState()
|
||||||
setup.do_fixture_and_runtest(item)
|
setup.do_fixture_and_runtest(item)
|
||||||
rep = evrec.popevent("itemtestreport").rep
|
rep = evrec.popcall("itemtestreport").rep
|
||||||
assert rep.passed
|
assert rep.passed
|
||||||
|
|
||||||
def test_runtest_fails(self, testdir):
|
def test_runtest_fails(self, testdir):
|
||||||
|
@ -85,7 +85,7 @@ class TestSetupState:
|
||||||
evrec = testdir.geteventrecorder(item.config)
|
evrec = testdir.geteventrecorder(item.config)
|
||||||
setup = SetupState()
|
setup = SetupState()
|
||||||
setup.do_fixture_and_runtest(item)
|
setup.do_fixture_and_runtest(item)
|
||||||
event = evrec.popevent("item_runtest_finished")
|
event = evrec.popcall("item_runtest_finished")
|
||||||
assert event.excinfo
|
assert event.excinfo
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,9 @@ class SessionTests:
|
||||||
assert failed[0].colitem.name == "test_one_one"
|
assert failed[0].colitem.name == "test_one_one"
|
||||||
assert failed[1].colitem.name == "test_other"
|
assert failed[1].colitem.name == "test_other"
|
||||||
assert failed[2].colitem.name == "test_two"
|
assert failed[2].colitem.name == "test_two"
|
||||||
itemstarted = sorter.getevents("itemstart")
|
itemstarted = sorter.getcalls("itemstart")
|
||||||
assert len(itemstarted) == 4
|
assert len(itemstarted) == 4
|
||||||
colstarted = sorter.getevents("collectionstart")
|
colstarted = sorter.getcalls("collectionstart")
|
||||||
assert len(colstarted) == 1
|
assert len(colstarted) == 1
|
||||||
col = colstarted[0].collector
|
col = colstarted[0].collector
|
||||||
assert isinstance(col, py.test.collect.Module)
|
assert isinstance(col, py.test.collect.Module)
|
||||||
|
@ -202,7 +202,7 @@ class TestNewSession(SessionTests):
|
||||||
itemstarted = sorter.getnamed("itemstart")
|
itemstarted = sorter.getnamed("itemstart")
|
||||||
assert len(itemstarted) == 3
|
assert len(itemstarted) == 3
|
||||||
assert not sorter.getnamed("itemtestreport")
|
assert not sorter.getnamed("itemtestreport")
|
||||||
started = sorter.getevents("collectionstart")
|
started = sorter.getcalls("collectionstart")
|
||||||
finished = sorter.getnamed("collectionreport")
|
finished = sorter.getnamed("collectionreport")
|
||||||
assert len(started) == len(finished)
|
assert len(started) == len(finished)
|
||||||
assert len(started) == 8
|
assert len(started) == 8
|
||||||
|
|
Loading…
Reference in New Issue