[pytest-dev] Hook validation difference between conftest files and plugins
bubenkoff at gmail.com
Sun Sep 28 23:38:47 CEST 2014
I had the same problem
solved it by 'deferring' a plugin hook a bit:
On 28 September 2014 22:46, Bruno Oliveira <nicoddemus at gmail.com> 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,
> _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.
> Pytest-dev mailing list
> Pytest-dev at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Pytest-dev