rename recorder functionality, unify interfaces

--HG--
branch : trunk
This commit is contained in:
holger krekel 2009-05-19 19:25:21 +02:00
parent 17762db128
commit 1973817f11
17 changed files with 146 additions and 157 deletions

View File

@ -4,7 +4,7 @@ from py.__.execnet.gateway import ExecnetAPI
class TestExecnetEvents:
def test_popengateway(self, _pytest):
rec = _pytest.getcallrecorder(ExecnetAPI)
rec = _pytest.gethookrecorder(ExecnetAPI)
gw = py.execnet.PopenGateway()
call = rec.popcall("pyexecnet_gateway_init")
assert call.gateway == gw

View File

@ -21,7 +21,7 @@ class TestGatewayManagerPopen:
assert spec.chdir == "abc"
def test_popen_makegateway_events(self, _pytest):
rec = _pytest.getcallrecorder(py.execnet._HookSpecs)
rec = _pytest.gethookrecorder(py.execnet._HookSpecs)
hm = GatewayManager(["popen"] * 2)
hm.makegateways()
call = rec.popcall("pyexecnet_gwmanage_newgateway")
@ -63,7 +63,7 @@ class TestGatewayManagerPopen:
def test_hostmanage_rsync_same_popen_twice(self, mysetup, _pytest):
source, dest = mysetup.source, mysetup.dest
rec = _pytest.getcallrecorder(py.execnet._HookSpecs)
rec = _pytest.gethookrecorder(py.execnet._HookSpecs)
hm = GatewayManager(["popen//chdir=%s" %dest] * 2)
hm.makegateways()
source.ensure("dir1", "dir2", "hello")

View File

@ -174,13 +174,13 @@ class TestDSession:
session.senditems_load([item1, item2])
node = session.item2nodes[item1] [0]
session.queueevent("pytest_testnodedown", node=node, error=None)
evrec = testdir.geteventrecorder(session.pluginmanager)
reprec = testdir.getreportrecorder(session.pluginmanager)
print session.item2nodes
loopstate = session._initloopstate([])
session.loop_once(loopstate)
assert loopstate.colitems == [item2] # do not reschedule crash item
testrep = evrec.matchreport(names="itemtestreport")
testrep = reprec.matchreport(names="pytest_itemtestreport")
assert testrep.failed
assert testrep.colitem == item1
assert str(testrep.longrepr).find("crashed") != -1
@ -261,13 +261,13 @@ class TestDSession:
session.addnode(node)
loopstate = session._initloopstate([])
loopstate.shuttingdown = True
evrec = testdir.geteventrecorder(session.pluginmanager)
reprec = testdir.getreportrecorder(session.pluginmanager)
session.queueevent("pytest_itemtestreport", rep=run(item, node))
session.loop_once(loopstate)
assert not evrec.getcalls("pytest_testnodedown")
assert not reprec.getcalls("pytest_testnodedown")
session.queueevent("pytest_testnodedown", node=node, error=None)
session.loop_once(loopstate)
assert evrec.getcall('pytest_testnodedown').node == node
assert reprec.getcall('pytest_testnodedown').node == node
def test_filteritems(self, testdir):
modcol = testdir.getmodulecol("""
@ -282,18 +282,18 @@ class TestDSession:
dsel = session.filteritems([modcol])
assert dsel == [modcol]
items = modcol.collect()
callrecorder = testdir.geteventrecorder(session.pluginmanager).callrecorder
hookrecorder = testdir.getreportrecorder(session.pluginmanager).hookrecorder
remaining = session.filteritems(items)
assert remaining == []
event = callrecorder.getcalls("pytest_deselected")[-1]
event = hookrecorder.getcalls("pytest_deselected")[-1]
assert event.items == items
modcol.config.option.keyword = "test_fail"
remaining = session.filteritems(items)
assert remaining == [items[0]]
event = callrecorder.getcalls("pytest_deselected")[-1]
event = hookrecorder.getcalls("pytest_deselected")[-1]
assert event.items == [items[1]]
def test_testnodedown_shutdown_after_completion(self, testdir):
@ -355,16 +355,16 @@ class TestDSession:
""")
config = testdir.parseconfig('-d', p1, '--tx=popen')
dsession = DSession(config)
callrecorder = testdir.geteventrecorder(config.pluginmanager).callrecorder
hookrecorder = testdir.getreportrecorder(config.pluginmanager).hookrecorder
dsession.main([config.getfsnode(p1)])
rep = callrecorder.popcall("pytest_itemtestreport").rep
rep = hookrecorder.popcall("pytest_itemtestreport").rep
assert rep.passed
rep = callrecorder.popcall("pytest_itemtestreport").rep
rep = hookrecorder.popcall("pytest_itemtestreport").rep
assert rep.skipped
rep = callrecorder.popcall("pytest_itemtestreport").rep
rep = hookrecorder.popcall("pytest_itemtestreport").rep
assert rep.failed
# see that the node is really down
node = callrecorder.popcall("pytest_testnodedown").node
node = hookrecorder.popcall("pytest_testnodedown").node
assert node.gateway.spec.popen
#XXX eq.geteventargs("pytest_testrunfinish")

View File

@ -107,7 +107,7 @@ class TestNodeManager:
config = py.test.config._reparse([source, '--debug'])
assert config.option.debug
nodemanager = NodeManager(config, specs)
sorter = testdir.geteventrecorder(config.pluginmanager).callrecorder
sorter = testdir.getreportrecorder(config.pluginmanager).hookrecorder
nodemanager.setup_nodes(putevent=[].append)
for spec in nodemanager.gwmanager.specs:
l = sorter.getcalls("pytest_trace")

View File

@ -7,14 +7,13 @@ class PytestArg:
def __init__(self, request):
self.request = request
def getcallrecorder(self, hookspecs, comregistry=None):
def gethookrecorder(self, hookspecs, comregistry=None):
if comregistry is None:
comregistry = self.request.config.pluginmanager.comregistry
callrecorder = CallRecorder(comregistry)
callrecorder.start_recording(hookspecs)
self.request.addfinalizer(callrecorder.finalize)
return callrecorder
hookrecorder = HookRecorder(comregistry)
hookrecorder.start_recording(hookspecs)
self.request.addfinalizer(hookrecorder.finish_recording)
return hookrecorder
class ParsedCall:
def __init__(self, name, locals):
@ -28,7 +27,7 @@ class ParsedCall:
del d['_name']
return "<ParsedCall %r(**%r)>" %(self._name, d)
class CallRecorder:
class HookRecorder:
def __init__(self, comregistry):
self._comregistry = comregistry
self.calls = []
@ -40,23 +39,18 @@ class CallRecorder:
_recorder = self
for name, method in vars(hookspecs).items():
if name[0] != "_":
setattr(RecordCalls, name, self._getcallparser(method))
setattr(RecordCalls, name, self._makecallparser(method))
recorder = RecordCalls()
self._recorders[hookspecs] = recorder
self._comregistry.register(recorder)
self.hook = py._com.Hooks(hookspecs, registry=self._comregistry)
def finalize(self):
def finish_recording(self):
for recorder in self._recorders.values():
self._comregistry.unregister(recorder)
self._recorders.clear()
def recordsmethod(self, name):
for hookspecs in self._recorders:
if hasattr(hookspecs, name):
return True
def _getcallparser(self, method):
def _makecallparser(self, method):
name = method.__name__
args, varargs, varkw, default = py.std.inspect.getargspec(method)
assert args[0] == "self"
@ -72,13 +66,6 @@ class CallRecorder:
""" % locals())
return locals()[name]
def popcall(self, name):
for i, call in py.builtin.enumerate(self.calls):
if call._name == name:
del self.calls[i]
return call
raise ValueError("could not find call %r in %r" %(name, self.calls))
def getcalls(self, names):
if isinstance(names, str):
names = names.split()
@ -95,12 +82,25 @@ class CallRecorder:
l.append(call)
return l
def popcall(self, name):
for i, call in py.builtin.enumerate(self.calls):
if call._name == name:
del self.calls[i]
return call
raise ValueError("could not find call %r in %r" %(name, self.calls))
def getcall(self, name):
l = self.getcalls(name)
assert len(l) == 1, (name, l)
return l[0]
def test_generic(plugintester):
plugintester.hookcheck()
def test_callrecorder_basic():
def test_hookrecorder_basic():
comregistry = py._com.Registry()
rec = CallRecorder(comregistry)
rec = HookRecorder(comregistry)
class ApiClass:
def xyz(self, arg):
pass
@ -118,7 +118,7 @@ def test_functional(testdir, linecomp):
def test_func(_pytest):
class ApiClass:
def xyz(self, arg): pass
rec = _pytest.getcallrecorder(ApiClass)
rec = _pytest.gethookrecorder(ApiClass)
class Plugin:
def xyz(self, arg):
return arg + 1

View File

@ -93,7 +93,7 @@ class TestDoctests:
def test_collect_module(self, testdir):
path = testdir.makepyfile(whatever="#")
for p in (path, testdir.tmpdir):
items, evrec = testdir.inline_genitems(p, '--doctest-modules')
items, reprec = testdir.inline_genitems(p, '--doctest-modules')
assert len(items) == 1
assert isinstance(items[0], DoctestModule)

View File

@ -30,20 +30,20 @@ def test_generic(plugintester):
class TestCapture:
def test_std_functional(self, testdir):
evrec = testdir.inline_runsource("""
reprec = testdir.inline_runsource("""
def test_hello(stdcapture):
print 42
out, err = stdcapture.reset()
assert out.startswith("42")
""")
evrec.assertoutcome(passed=1)
reprec.assertoutcome(passed=1)
def test_stdfd_functional(self, testdir):
evrec = testdir.inline_runsource("""
reprec = testdir.inline_runsource("""
def test_hello(stdcapturefd):
import os
os.write(1, "42")
out, err = stdcapturefd.reset()
assert out.startswith("42")
""")
evrec.assertoutcome(passed=1)
reprec.assertoutcome(passed=1)

View File

@ -57,10 +57,10 @@ def test_toproxy(testdir, monkeypatch):
def test_skip():
py.test.skip("")
""")
evrec = testdir.inline_run(testpath, "-P")
reprec = testdir.inline_run(testpath, "-P")
assert len(l) == 1
assert l[0][0] == "python"
s = l[0][1]
assert s.find("def test_fail") != -1
assert evrec.countoutcomes() == [1,1,1]
assert reprec.countoutcomes() == [1,1,1]

View File

@ -7,9 +7,10 @@ import os
import inspect
from py.__.test import runner
from py.__.test.config import Config as pytestConfig
from pytest__pytest import CallRecorder
from pytest__pytest import HookRecorder
import api
def pytest_funcarg__linecomp(request):
return LineComp()
@ -20,10 +21,10 @@ def pytest_funcarg__testdir(request):
tmptestdir = TmpTestdir(request)
return tmptestdir
def pytest_funcarg__eventrecorder(request):
evrec = EventRecorder(py._com.comregistry)
request.addfinalizer(lambda: evrec.comregistry.unregister(evrec))
return evrec
def pytest_funcarg__reportrecorder(request):
reprec = ReportRecorder(py._com.comregistry)
request.addfinalizer(lambda: reprec.comregistry.unregister(reprec))
return reprec
def test_generic(plugintester):
plugintester.hookcheck()
@ -72,12 +73,12 @@ class TmpTestdir:
if hasattr(self, '_olddir'):
self._olddir.chdir()
def geteventrecorder(self, registry):
sorter = EventRecorder(registry)
sorter.callrecorder = CallRecorder(registry)
sorter.callrecorder.start_recording(api.PluginHooks)
sorter.hook = sorter.callrecorder.hook
self.request.addfinalizer(sorter.callrecorder.finalize)
def getreportrecorder(self, registry):
sorter = ReportRecorder(registry)
sorter.hookrecorder = HookRecorder(registry)
sorter.hookrecorder.start_recording(api.PluginHooks)
sorter.hook = sorter.hookrecorder.hook
self.request.addfinalizer(sorter.hookrecorder.finish_recording)
return sorter
def chdir(self):
@ -129,7 +130,7 @@ class TmpTestdir:
#config = self.parseconfig(*args)
config = self.parseconfig(*args)
session = config.initsession()
rec = self.geteventrecorder(config.pluginmanager)
rec = self.getreportrecorder(config.pluginmanager)
colitems = [config.getfsnode(arg) for arg in config.args]
items = list(session.genitems(colitems))
return items, rec
@ -151,7 +152,7 @@ class TmpTestdir:
config = self.parseconfig(*args)
config.pluginmanager.do_configure(config)
session = config.initsession()
sorter = self.geteventrecorder(config.pluginmanager)
sorter = self.getreportrecorder(config.pluginmanager)
session.main()
config.pluginmanager.do_unconfigure(config)
return sorter
@ -161,10 +162,12 @@ class TmpTestdir:
for plugin in self.plugins:
if isinstance(plugin, str):
config.pluginmanager.import_plugin(plugin)
elif plugin:
else:
if isinstance(plugin, dict):
plugin = PseudoPlugin(plugin)
if not config.pluginmanager.isregistered(plugin):
config.pluginmanager.register(plugin)
#print "config.pluginmanager.impname2plugin", config.pluginmanager.impname2plugin
return config
def parseconfig(self, *args):
@ -284,55 +287,24 @@ class PseudoPlugin:
def __init__(self, vars):
self.__dict__.update(vars)
class Event:
def __init__(self, name, args, kwargs):
self.name = name
self.args = args
self.kwargs = kwargs
def __repr__(self):
return "<Event %r %r>" %(self.name, self.args)
class ParsedCall:
def __init__(self, locals):
self.__dict__ = locals.copy()
def __repr__(self):
return "<ParsedCall %r>" %(self.__dict__,)
class EventRecorder(object):
def __init__(self, comregistry, debug=False): # True):
class ReportRecorder(object):
def __init__(self, comregistry):
self.comregistry = comregistry
self.debug = debug
comregistry.register(self)
def getcall(self, name):
l = self.getcalls(name)
assert len(l) == 1, (name, l)
return l[0]
return self.hookrecorder.getcall(name)
def getcalls(self, *names):
def getcalls(self, names):
""" return list of ParsedCall instances matching the given eventname. """
if len(names) == 1 and isinstance(names, str):
names = names.split()
l = []
for name in names:
if self.callrecorder.recordsmethod("pytest_" + name):
name = "pytest_" + name
if self.callrecorder.recordsmethod(name):
l.extend(self.callrecorder.getcalls(name))
return l
return self.hookrecorder.getcalls(names)
# functionality for test reports
def getreports(self, names="itemtestreport collectreport"):
names = [("pytest_" + x) for x in names.split()]
l = []
for call in self.getcalls(*names):
l.append(call.rep)
return l
def getreports(self, names="pytest_itemtestreport pytest_collectreport"):
return [x.rep for x in self.getcalls(names)]
def matchreport(self, inamepart="", names="itemtestreport collectreport"):
def matchreport(self, inamepart="", names="pytest_itemtestreport pytest_collectreport"):
""" return a testreport whose dotted import path matches """
l = []
for rep in self.getreports(names=names):
@ -346,21 +318,17 @@ class EventRecorder(object):
inamepart, l))
return l[0]
def getfailures(self, names='itemtestreport collectreport'):
l = []
for call in self.getcalls(*names.split()):
if call.rep.failed:
l.append(call.rep)
return l
def getfailures(self, names='pytest_itemtestreport pytest_collectreport'):
return [rep for rep in self.getreports(names) if rep.failed]
def getfailedcollections(self):
return self.getfailures('collectreport')
return self.getfailures('pytest_collectreport')
def listoutcomes(self):
passed = []
skipped = []
failed = []
for rep in self.getreports("itemtestreport"):
for rep in self.getreports("pytest_itemtestreport"):
if rep.passed:
passed.append(rep)
elif rep.skipped:
@ -379,15 +347,15 @@ class EventRecorder(object):
assert failed == len(realfailed)
def clear(self):
self.callrecorder.calls[:] = []
self.hookrecorder.calls[:] = []
def unregister(self):
self.comregistry.unregister(self)
self.callrecorder.finalize()
self.hookrecorder.finish_recording()
def test_eventrecorder(testdir):
def test_reportrecorder(testdir):
registry = py._com.Registry()
recorder = testdir.geteventrecorder(registry)
recorder = testdir.getreportrecorder(registry)
assert not recorder.getfailures()
rep = runner.ItemTestReport(None, None)
rep.passed = False
@ -406,7 +374,7 @@ def test_eventrecorder(testdir):
rep = runner.CollectReport(None, None)
rep.passed = False
rep.failed = True
recorder.hook.pytest_itemtestreport(rep=rep)
recorder.hook.pytest_collectreport(rep=rep)
passed, skipped, failed = recorder.listoutcomes()
assert not passed and skipped and failed
@ -414,13 +382,13 @@ def test_eventrecorder(testdir):
numpassed, numskipped, numfailed = recorder.countoutcomes()
assert numpassed == 0
assert numskipped == 1
assert numfailed == 2
assert numfailed == 1
assert len(recorder.getfailedcollections()) == 1
recorder.unregister()
recorder.clear()
assert not recorder.getfailures()
recorder.hook.pytest_itemtestreport(rep=rep)
assert not recorder.getfailures()
py.test.raises(ValueError, "recorder.getfailures()")
class LineComp:
def __init__(self):

View File

@ -208,7 +208,7 @@ class TestRunnerPlugin:
item = testdir.getitem("""def test_func(): pass""")
plugin = RunnerPlugin()
plugin.pytest_configure(item.config)
sorter = testdir.geteventrecorder(item.config.pluginmanager)
sorter = testdir.getreportrecorder(item.config.pluginmanager)
plugin.pytest_item_setup_and_runtest(item)
rep = sorter.getcall("pytest_itemtestreport").rep
assert rep.passed
@ -248,7 +248,7 @@ class TestSetupEvents:
print "13"
raise ValueError(25)
""")
rep = evrec.popcall(pytest_itemsetupreport).rep
rep = reprec.popcall(pytest_itemsetupreport).rep
assert rep.failed
assert rep.item == item
assert not rep.passed

View File

@ -20,10 +20,18 @@ class PluginManager(object):
hookspecs=api.PluginHooks,
registry=self.comregistry)
def register(self, plugin, name=None):
def _getpluginname(self, plugin, name):
if name is None:
name = getattr(plugin, '__name__', id(plugin))
if name not in self.impname2plugin:
if hasattr(plugin, '__name__'):
name = plugin.__name__.split(".")[-1]
else:
name = id(plugin)
return name
def register(self, plugin, name=None):
assert not self.isregistered(plugin)
name = self._getpluginname(plugin, name)
assert name not in self.impname2plugin
self.impname2plugin[name] = plugin
self.hook.pytest_plugin_registered(plugin=plugin)
self.comregistry.register(plugin)
@ -36,8 +44,8 @@ class PluginManager(object):
if value == plugin:
del self.impname2plugin[name]
def isregistered(self, plugin):
return self.comregistry.isregistered(plugin)
def isregistered(self, plugin, name=None):
return self._getpluginname(plugin, name) in self.impname2plugin
def getplugins(self):
return list(self.comregistry)

View File

@ -175,7 +175,7 @@ class TestCollectPluginHooks:
assert "hello" in wascalled
assert "world" in wascalled
# make sure the directories do not get double-appended
colreports = sorter.getreports("collectreport")
colreports = sorter.getreports("pytest_collectreport")
names = [rep.colitem.name for rep in colreports]
assert names.count("hello") == 1
@ -214,8 +214,8 @@ class TestCustomConftests:
""")
testdir.mkdir("hello")
sorter = testdir.inline_run(testdir.tmpdir)
names = [rep.colitem.name for rep in sorter.getreports("collectreport")]
names = [rep.colitem.name for rep in sorter.getreports("pytest_collectreport")]
assert 'hello' not in names
evrec = testdir.inline_run(testdir.tmpdir, "--XX")
names = [rep.colitem.name for rep in evrec.getreports("collectreport")]
reprec = testdir.inline_run(testdir.tmpdir, "--XX")
names = [rep.colitem.name for rep in reprec.getreports("pytest_collectreport")]
assert 'hello' in names

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.getcalls('deselected')) == 1
assert len(sorter.getcalls('pytest_deselected')) == 1
for keyword in ['test_one', 'est_on']:
#yield check, keyword, 'test_one'

View File

@ -74,7 +74,7 @@ class TestBootstrapping:
mod.pytest_plugins = "pytest_a"
aplugin = testdir.makepyfile(pytest_a="#")
pluginmanager = PluginManager()
sorter = testdir.geteventrecorder(pluginmanager)
sorter = testdir.getreportrecorder(pluginmanager)
#syspath.prepend(aplugin.dirpath())
py.std.sys.path.insert(0, str(aplugin.dirpath()))
pluginmanager.consider_module(mod)
@ -83,7 +83,7 @@ class TestBootstrapping:
# check that it is not registered twice
pluginmanager.consider_module(mod)
l = sorter.getcalls("plugin_registered")
l = sorter.getcalls("pytest_plugin_registered")
assert len(l) == 1
def test_consider_conftest_deprecated(self, testdir):
@ -113,6 +113,19 @@ class TestBootstrapping:
pp.unregister(a2)
assert not pp.isregistered(a2)
def test_register_imported_modules(self):
pp = PluginManager()
mod = py.std.new.module("x.y.pytest_hello")
pp.register(mod)
assert pp.isregistered(mod)
assert pp.getplugins() == [mod]
py.test.raises(AssertionError, "pp.register(mod)")
mod2 = py.std.new.module("pytest_hello")
#pp.register(mod2) # double registry
py.test.raises(AssertionError, "pp.register(mod)")
#assert not pp.isregistered(mod2)
assert pp.getplugins() == [mod] # does not actually modify plugins
def test_canonical_importname(self):
for name in 'xyz', 'pytest_xyz', 'pytest_Xyz', 'Xyz':
impname = canonical_importname(name)

View File

@ -19,7 +19,7 @@ class TestSetupStateFunctional:
def test_func():
pass
""")
evrec = testdir.geteventrecorder(item.config)
reprec = testdir.getreportrecorder(item.config)
setup = SetupState()
res = setup.do_setup(item)
assert res
@ -32,11 +32,11 @@ class TestSetupStateFunctional:
def test_func():
pass
""")
evrec = testdir.geteventrecorder(item.config)
reprec = testdir.getreportrecorder(item.config)
setup = SetupState()
res = setup.do_setup(item)
assert not res
rep = evrec.popcall(pytest_itemsetupreport).rep
rep = reprec.popcall(pytest_itemsetupreport).rep
assert rep.failed
assert not rep.skipped
assert rep.excrepr
@ -51,14 +51,14 @@ class TestSetupStateFunctional:
print "13"
raise ValueError(25)
""")
evrec = testdir.geteventrecorder(item.config)
reprec = testdir.getreportrecorder(item.config)
setup = SetupState()
res = setup.do_setup(item)
assert res
rep = evrec.popcall(pytest_itemsetupreport).rep
rep = reprec.popcall(pytest_itemsetupreport).rep
assert rep.passed
setup.do_teardown(item)
rep = evrec.popcall(pytest_itemsetupreport).rep
rep = reprec.popcall(pytest_itemsetupreport).rep
assert rep.item == item
assert rep.failed
assert not rep.passed
@ -73,10 +73,10 @@ class TestSetupStateFunctional:
def test_func():
pass
""")
evrec = testdir.geteventrecorder(item.config)
reprec = testdir.getreportrecorder(item.config)
setup = SetupState()
setup.do_setup(item)
rep = evrec.popcall(pytest_itemsetupreport).rep
rep = reprec.popcall(pytest_itemsetupreport).rep
assert not rep.failed
assert rep.skipped
assert rep.excrepr
@ -84,18 +84,18 @@ class TestSetupStateFunctional:
def test_runtest_ok(self, testdir):
item = testdir.getitem("def test_func(): pass")
evrec = testdir.geteventrecorder(item.config)
reprec = testdir.getreportrecorder(item.config)
setup = SetupState()
setup.do_fixture_and_runtest(item)
rep = evrec.popcall(pytest_itemtestreport).rep
rep = reprec.popcall(pytest_itemtestreport).rep
assert rep.passed
def test_runtest_fails(self, testdir):
item = testdir.getitem("def test_func(): assert 0")
evrec = testdir.geteventrecorder(item.config)
reprec = testdir.getreportrecorder(item.config)
setup = SetupState()
setup.do_fixture_and_runtest(item)
event = evrec.popcall(pytest_item_runtest_finished)
event = reprec.popcall(pytest_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.getcalls("itemstart")
itemstarted = sorter.getcalls("pytest_itemstart")
assert len(itemstarted) == 4
colstarted = sorter.getcalls("collectstart")
colstarted = sorter.getcalls("pytest_collectstart")
assert len(colstarted) == 1
col = colstarted[0].collector
assert isinstance(col, py.test.collect.Module)
@ -130,7 +130,7 @@ class SessionTests:
def test_one(): pass
""")
sorter = testdir.inline_run(testdir.tmpdir)
reports = sorter.getreports("collectreport")
reports = sorter.getreports("pytest_collectreport")
assert len(reports) == 1
assert reports[0].skipped
@ -201,9 +201,9 @@ class TestNewSession(SessionTests):
itemstarted = sorter.getcalls("pytest_itemstart")
assert len(itemstarted) == 3
assert not sorter.getreports("itemtestreport")
assert not sorter.getreports("pytest_itemtestreport")
started = sorter.getcalls("pytest_collectstart")
finished = sorter.getreports("collectreport")
finished = sorter.getreports("pytest_collectreport")
assert len(started) == len(finished)
assert len(started) == 8
colfail = [x for x in finished if x.failed]
@ -215,7 +215,7 @@ class TestNewSession(SessionTests):
testdir.makepyfile(__init__="")
testdir.makepyfile(test_one="xxxx", test_two="yyyy")
sorter = testdir.inline_run("-x", testdir.tmpdir)
finished = sorter.getreports("collectreport")
finished = sorter.getreports("pytest_collectreport")
colfail = [x for x in finished if x.failed]
assert len(colfail) == 1

View File

@ -118,7 +118,7 @@ def test_func_generator_setup(testdir):
yield check
assert x == [1]
""")
rep = sorter.matchreport("test_one", names="itemtestreport")
rep = sorter.matchreport("test_one", names="pytest_itemtestreport")
assert rep.passed
def test_method_setup_uses_fresh_instances(testdir):