avoid prepend to register api as it's redundant wrt to hooks
--HG-- branch : plugin_no_pytest
This commit is contained in:
parent
1ef49ac5ab
commit
7049ebe4e2
|
@ -205,7 +205,7 @@ class PluginManager(object):
|
||||||
", ".join(hook.argnames))
|
", ".join(hook.argnames))
|
||||||
yield hook
|
yield hook
|
||||||
|
|
||||||
def register(self, plugin, name=None, prepend=False, conftest=False):
|
def register(self, plugin, name=None, conftest=False):
|
||||||
if self._name2plugin.get(name, None) == -1:
|
if self._name2plugin.get(name, None) == -1:
|
||||||
return
|
return
|
||||||
name = name or getattr(plugin, '__name__', str(id(plugin)))
|
name = name or getattr(plugin, '__name__', str(id(plugin)))
|
||||||
|
@ -222,10 +222,7 @@ class PluginManager(object):
|
||||||
if conftest:
|
if conftest:
|
||||||
self._conftestplugins.append(plugin)
|
self._conftestplugins.append(plugin)
|
||||||
else:
|
else:
|
||||||
if not prepend:
|
|
||||||
self._plugins.append(plugin)
|
self._plugins.append(plugin)
|
||||||
else:
|
|
||||||
self._plugins.insert(0, plugin)
|
|
||||||
# finally make sure that the methods of the new plugin take part
|
# finally make sure that the methods of the new plugin take part
|
||||||
for hookcaller in hookcallers:
|
for hookcaller in hookcallers:
|
||||||
hookcaller.scan_methods()
|
hookcaller.scan_methods()
|
||||||
|
|
|
@ -510,7 +510,7 @@ class Session(FSCollector):
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
FSCollector.__init__(self, config.rootdir, parent=None,
|
FSCollector.__init__(self, config.rootdir, parent=None,
|
||||||
config=config, session=self)
|
config=config, session=self)
|
||||||
self.config.pluginmanager.register(self, name="session", prepend=True)
|
self.config.pluginmanager.register(self, name="session")
|
||||||
self._testsfailed = 0
|
self._testsfailed = 0
|
||||||
self.shouldstop = False
|
self.shouldstop = False
|
||||||
self.trace = config.trace.root.get("collection")
|
self.trace = config.trace.root.get("collection")
|
||||||
|
@ -521,10 +521,12 @@ class Session(FSCollector):
|
||||||
def _makeid(self):
|
def _makeid(self):
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
@pytest.mark.tryfirst
|
||||||
def pytest_collectstart(self):
|
def pytest_collectstart(self):
|
||||||
if self.shouldstop:
|
if self.shouldstop:
|
||||||
raise self.Interrupted(self.shouldstop)
|
raise self.Interrupted(self.shouldstop)
|
||||||
|
|
||||||
|
@pytest.mark.tryfirst
|
||||||
def pytest_runtest_logreport(self, report):
|
def pytest_runtest_logreport(self, report):
|
||||||
if report.failed and not hasattr(report, 'wasxfail'):
|
if report.failed and not hasattr(report, 'wasxfail'):
|
||||||
self._testsfailed += 1
|
self._testsfailed += 1
|
||||||
|
|
|
@ -32,18 +32,6 @@ class TestPluginManager:
|
||||||
pm.unregister(a1)
|
pm.unregister(a1)
|
||||||
assert not pm.isregistered(a1)
|
assert not pm.isregistered(a1)
|
||||||
|
|
||||||
def test_pm_ordering(self, pm):
|
|
||||||
class A: pass
|
|
||||||
a1, a2 = A(), A()
|
|
||||||
pm.register(a1)
|
|
||||||
pm.register(a2, "hello")
|
|
||||||
l = pm.getplugins()
|
|
||||||
assert l.index(a1) < l.index(a2)
|
|
||||||
a3 = A()
|
|
||||||
pm.register(a3, prepend=True)
|
|
||||||
l = pm.getplugins()
|
|
||||||
assert l.index(a3) == 0
|
|
||||||
|
|
||||||
def test_register_mismatch_method(self):
|
def test_register_mismatch_method(self):
|
||||||
pm = get_plugin_manager()
|
pm = get_plugin_manager()
|
||||||
class hello:
|
class hello:
|
||||||
|
|
Loading…
Reference in New Issue