add a way to mark hooks as "tryfirst" or "trylast" to influence its position in a hook chain.

Use 'tryfirst' for capturing hooks so they can start capturing as early as possible,
including when conftests add output in runtest_setup hooks.
This commit is contained in:
holger krekel
2010-11-21 23:17:59 +01:00
parent f456e376b9
commit bc42cf8ffb
8 changed files with 62 additions and 9 deletions

View File

@@ -12,7 +12,7 @@ assert py.__version__.split(".")[:2] >= ['2', '0'], ("installation problem: "
"%s is too old, remove or upgrade 'py'" % (py.__version__))
default_plugins = (
"config session terminal runner python pdb capture unittest mark skipping "
"config mark session terminal runner python pdb unittest capture skipping "
"tmpdir monkeypatch recwarn pastebin helpconfig nose assertion genscript "
"junitxml doctest").split()
@@ -272,11 +272,19 @@ class PluginManager(object):
if plugins is None:
plugins = self._plugins
l = []
last = []
for plugin in plugins:
try:
l.append(getattr(plugin, attrname))
meth = getattr(plugin, attrname)
if hasattr(meth, 'tryfirst'):
last.append(meth)
elif hasattr(meth, 'trylast'):
l.insert(0, meth)
else:
l.append(meth)
except AttributeError:
continue
l.extend(last)
return l
def call_plugin(self, plugin, methname, kwargs):