I had the same problem solved it by 'deferring' a plugin hook a bit: https://github.com/pytest-dev/pytest-splinter/blob/master/pytest_splinter/plugin.py#L333
On 28 September 2014 22:46, Bruno Oliveira <[email protected]> wrote: > Hi everyone, > > 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. > > 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. > > Here is an example: > > # contents of conftest.py > def pytest_configure_node(node): > assert 0, 'configure_node called' > > # contents of test_foo.py > def test_foo(): pass > > In a fresh virtual environment with `pytest-xdist` installed: > > > $ py.test -n2 > <snip traceback> > INTERNALERROR> AssertionError: configure_node called > > OK, that's what I expected. > > On the other hand, renaming `conftest.py` to `myplugin.py`: > > $ py.test -n2 -p myplugin > raise PluginValidationError("%s:\n%s" % (name, > stringio.getvalue())) > _pytest.helpconfig.PluginValidationError: myplugin: > found unknown hook: pytest_configure_node > > (You might have to configure your $PYTHONPATH to the working directory) > > The same happens if I make a plugin using setup.py/setuptools. > > Am I missing something, or is this a bug? > > 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. > > Cheers, > Bruno. > > _______________________________________________ > Pytest-dev mailing list > [email protected] > https://mail.python.org/mailman/listinfo/pytest-dev > > -- Anatoly Bubenkov
_______________________________________________ Pytest-dev mailing list [email protected] https://mail.python.org/mailman/listinfo/pytest-dev
