<div dir="ltr">I had the same problem<div>solved it by 'deferring' a plugin hook a bit:</div><div><br></div><div><a href="https://github.com/pytest-dev/pytest-splinter/blob/master/pytest_splinter/plugin.py#L333">https://github.com/pytest-dev/pytest-splinter/blob/master/pytest_splinter/plugin.py#L333</a><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 28 September 2014 22:46, Bruno Oliveira <span dir="ltr"><<a href="mailto:nicoddemus@gmail.com" target="_blank">nicoddemus@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi everyone,<div><br></div><div>I'm having some trouble when trying to use some of xdist-defined hooks in a plugin, but I believe this problem is not related to xdist specifically.<br><div><br></div><div>If I redefine a few of `xdist`'s hook functions inside a conftest file, it works fine. Once I move them to an external plugin however, I start getting "found unknown hook" errors.</div><div><br></div><div>Here is an example:</div><div><br></div><div> # contents of conftest.py</div><div><div> def pytest_configure_node(node):</div><div> assert 0, 'configure_node called'</div><div><br></div><div> # contents of test_foo.py</div><div> def test_foo(): pass</div></div><div><br></div><div>In a fresh virtual environment with `pytest-xdist` installed:</div><div><br></div><div> </div><div> $ py.test -n2</div><div> <snip traceback></div><div> INTERNALERROR> AssertionError: configure_node called</div><div></div></div><div><br></div><div>OK, that's what I expected. </div><div><br></div><div>On the other hand, renaming `conftest.py` to `myplugin.py`:</div><div><br></div><div><div> $ py.test -n2 -p myplugin</div><div><div> raise PluginValidationError("%s:\n%s" % (name, stringio.getvalue()))</div><div> _pytest.helpconfig.PluginValidationError: myplugin:</div><div> found unknown hook: pytest_configure_node</div></div></div><div><br></div><div>(You might have to configure your $PYTHONPATH to the working directory)</div><div><br></div><div>The same happens if I make a plugin using <a href="http://setup.py/setuptools" target="_blank">setup.py/setuptools</a>.</div><div><br></div><div>Am I missing something, or is this a bug?</div><div><br></div><div>Digging at the source a bit I found that plugin registration and hook validation happen one right after the other, which might be a problem because a plugin might depend on hooks that will be registered by other plugins later. </div><div><br></div><div>Cheers,</div><div>Bruno.</div></div>
<br>_______________________________________________<br>
Pytest-dev mailing list<br>
<a href="mailto:Pytest-dev@python.org">Pytest-dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/pytest-dev" target="_blank">https://mail.python.org/mailman/listinfo/pytest-dev</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Anatoly Bubenkov<br></div>
</div>