Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PluginValidationError: unknown hook 'pytest_fixture_plus' #71

Closed
adnanmuttaleb opened this issue Jan 6, 2020 · 3 comments
Closed

PluginValidationError: unknown hook 'pytest_fixture_plus' #71

adnanmuttaleb opened this issue Jan 6, 2020 · 3 comments

Comments

@adnanmuttaleb
Copy link

adnanmuttaleb commented Jan 6, 2020

I have installed pytest_cases, but when using it in conftest.py:

import pytest
from pytest_cases import pytest_fixture_plus, pytest_parametrize_plus

@pytest_fixture_plus(scope='module')
@pytest.mark.parametrize('name,description', [('cs', 'computer science')])
def domain(test_client, user, name, description):
  pass

I get the following error:

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/var/www/dictionary/venv/lib/python3.6/site-packages/_pytest/main.py", line 196, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/var/www/dictionary/venv/lib/python3.6/site-packages/_pytest/main.py", line 245, in _main
INTERNALERROR>     config.hook.pytest_collection(session=session)
INTERNALERROR>   File "/var/www/dictionary/venv/lib/python3.6/site-packages/pluggy/hooks.py", line 286, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/var/www/dictionary/venv/lib/python3.6/site-packages/pluggy/manager.py", line 93, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/var/www/dictionary/venv/lib/python3.6/site-packages/pluggy/manager.py", line 87, in <lambda>
INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR>   File "/var/www/dictionary/venv/lib/python3.6/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/var/www/dictionary/venv/lib/python3.6/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/var/www/dictionary/venv/lib/python3.6/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/var/www/dictionary/venv/lib/python3.6/site-packages/_pytest/main.py", line 255, in pytest_collection
INTERNALERROR>     return session.perform_collect()
INTERNALERROR>   File "/var/www/dictionary/venv/lib/python3.6/site-packages/_pytest/main.py", line 455, in perform_collect
INTERNALERROR>     self.config.pluginmanager.check_pending()
INTERNALERROR>   File "/var/www/dictionary/venv/lib/python3.6/site-packages/pluggy/manager.py", line 277, in check_pending
INTERNALERROR>     % (name, hookimpl.plugin),
INTERNALERROR> pluggy.manager.PluginValidationError: unknown hook 'pytest_fixture_plus' in plugin <module 'mo3jam
.tests.conftest' from '/var/www/.../tests/conftest.py'>

I tried to upgrade pluggy, but this did not work.

@smarie
Copy link
Owner

smarie commented Jan 16, 2020

Thanks ! I was able to reproduce this. You can even reproduce the same bug by having a single line in conftest.py:

from pytest_cases import pytest_fixture_plus

pytest thinks that pytest_fixture_plus is a plugin because it starts with pytest_ :)

@smarie
Copy link
Owner

smarie commented Jan 16, 2020

A quick workaround is to rename the symbol:

import pytest
from pytest_cases import pytest_fixture_plus as fixture_plus

@fixture_plus(scope='module')
@pytest.mark.parametrize('name,description', [('cs', 'computer science')])
def domain(test_client, user, name, description):
  pass

@smarie smarie closed this as completed in 4a5c618 Jan 17, 2020
smarie pushed a commit that referenced this issue Jan 17, 2020
…xture_plus` and `pytest_parametrize_plus` were renamed to `fixture_plus` and `parametrize_plus` in order for pytest (pluggy) not to think they were hooks. Old aliases will stay around for a few versions, with a deprecation warning. See [#71](#71).
@smarie
Copy link
Owner

smarie commented Jan 28, 2020

Fixed in 1.12.1 - sorry for the deployment delay, I actually forgot to tag :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants