Pytest-django: Unknown hook with latest pytest

Created on 2 Jun 2018  路  3Comments  路  Source: pytest-dev/pytest-django

After upgrading _pytest_ to 3.6.0 I am getting Unknown hook error:

[http@e6efef5e7fb9 app]$ pytest
===================================================================================== test session starts =====================================================================================
platform linux -- Python 3.6.5, pytest-3.6.0, py-1.5.3, pluggy-0.6.0
Django settings: app.test_settings (from ini file)
rootdir: /var/www/html/app, inifile: pytest.ini
plugins: django-3.2.1, cov-2.5.1
collecting 95 items                                                                                                                                                                           INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/usr/lib/python3.6/site-packages/_pytest/main.py", line 107, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/usr/lib/python3.6/site-packages/_pytest/main.py", line 144, in _main
INTERNALERROR>     config.hook.pytest_collection(session=session)
INTERNALERROR>   File "/usr/lib/python3.6/site-packages/pluggy/__init__.py", line 617, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/usr/lib/python3.6/site-packages/pluggy/__init__.py", line 222, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/usr/lib/python3.6/site-packages/pluggy/__init__.py", line 216, in <lambda>
INTERNALERROR>     firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR>   File "/usr/lib/python3.6/site-packages/pluggy/callers.py", line 201, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/usr/lib/python3.6/site-packages/pluggy/callers.py", line 76, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/usr/lib/python3.6/site-packages/pluggy/callers.py", line 180, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/usr/lib/python3.6/site-packages/_pytest/main.py", line 154, in pytest_collection
INTERNALERROR>     return session.perform_collect()
INTERNALERROR>   File "/usr/lib/python3.6/site-packages/_pytest/main.py", line 352, in perform_collect
INTERNALERROR>     self.config.pluginmanager.check_pending()
INTERNALERROR>   File "/usr/lib/python3.6/site-packages/pluggy/__init__.py", line 385, in check_pending
INTERNALERROR>     (name, hookimpl.plugin))
INTERNALERROR> pluggy.PluginValidationError: unknown hook 'pytest_django' in plugin <module 'functional_tests.conftest' (<_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7f43563f8668>)>

================================================================================ no tests ran in 1.55 seconds =================================================================================

This is content of _conftest.py_:

import pytest
import pytest_django.fixtures


@pytest.fixture(scope='module')
def django_db_setup(
    request,
    django_test_environment,
    django_db_blocker,
    django_db_use_migrations,
    django_db_keepdb,
    django_db_createdb,
    django_db_modify_db_settings,
):
    # temporarily no code here
    return pytest_django.fixtures.django_db_setup(
        request,
        django_test_environment,
        django_db_blocker,
        django_db_use_migrations,
        django_db_keepdb,
        django_db_createdb,
        django_db_modify_db_settings,
    )

Most helpful comment

Use this command

pip uninstall pytest-allure-adaptor
pip install allure-pytest

All 3 comments

I ran into a similar error. But upgrading pluggy seems to have solved it. I didn't have time to investigate but I now I have pytest==3.7.1, pytest-django==3.3.3 and pluggy==0.7.1 all working together.

Closing as per previous comment.

Use this command

pip uninstall pytest-allure-adaptor
pip install allure-pytest
Was this page helpful?
0 / 5 - 0 ratings

Related issues

tolomea picture tolomea  路  4Comments

dan-passaro picture dan-passaro  路  4Comments

ojake picture ojake  路  6Comments

mpasternak picture mpasternak  路  5Comments

ryankask picture ryankask  路  5Comments