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))
|
||||
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:
|
||||
return
|
||||
name = name or getattr(plugin, '__name__', str(id(plugin)))
|
||||
|
@ -222,10 +222,7 @@ class PluginManager(object):
|
|||
if conftest:
|
||||
self._conftestplugins.append(plugin)
|
||||
else:
|
||||
if not prepend:
|
||||
self._plugins.append(plugin)
|
||||
else:
|
||||
self._plugins.insert(0, plugin)
|
||||
self._plugins.append(plugin)
|
||||
# finally make sure that the methods of the new plugin take part
|
||||
for hookcaller in hookcallers:
|
||||
hookcaller.scan_methods()
|
||||
|
|
|
@ -510,7 +510,7 @@ class Session(FSCollector):
|
|||
def __init__(self, config):
|
||||
FSCollector.__init__(self, config.rootdir, parent=None,
|
||||
config=config, session=self)
|
||||
self.config.pluginmanager.register(self, name="session", prepend=True)
|
||||
self.config.pluginmanager.register(self, name="session")
|
||||
self._testsfailed = 0
|
||||
self.shouldstop = False
|
||||
self.trace = config.trace.root.get("collection")
|
||||
|
@ -521,10 +521,12 @@ class Session(FSCollector):
|
|||
def _makeid(self):
|
||||
return ""
|
||||
|
||||
@pytest.mark.tryfirst
|
||||
def pytest_collectstart(self):
|
||||
if self.shouldstop:
|
||||
raise self.Interrupted(self.shouldstop)
|
||||
|
||||
@pytest.mark.tryfirst
|
||||
def pytest_runtest_logreport(self, report):
|
||||
if report.failed and not hasattr(report, 'wasxfail'):
|
||||
self._testsfailed += 1
|
||||
|
|
|
@ -32,18 +32,6 @@ class TestPluginManager:
|
|||
pm.unregister(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):
|
||||
pm = get_plugin_manager()
|
||||
class hello:
|
||||
|
|
Loading…
Reference in New Issue