From 7049ebe4e254d0ae3d79ec0ddd684e3c77d7b83c Mon Sep 17 00:00:00 2001 From: holger krekel Date: Wed, 22 Apr 2015 13:31:46 +0200 Subject: [PATCH] avoid prepend to register api as it's redundant wrt to hooks --HG-- branch : plugin_no_pytest --- _pytest/core.py | 7 ++----- _pytest/main.py | 4 +++- testing/test_core.py | 12 ------------ 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/_pytest/core.py b/_pytest/core.py index 7d8bc5151..3d24ff98d 100644 --- a/_pytest/core.py +++ b/_pytest/core.py @@ -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() diff --git a/_pytest/main.py b/_pytest/main.py index 1250706db..96505e0da 100644 --- a/_pytest/main.py +++ b/_pytest/main.py @@ -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 diff --git a/testing/test_core.py b/testing/test_core.py index 50399919e..6323db435 100644 --- a/testing/test_core.py +++ b/testing/test_core.py @@ -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: