diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 1954766..0adb68e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,9 @@ UNRELEASED ---------- +- Use ``pytest.hookimpl`` to configure hooks, avoiding a deprecation warning in + the upcoming pytest 7.2.0. + 4.1.0 (2022-06-23) ------------------ diff --git a/src/pytestqt/logging.py b/src/pytestqt/logging.py index 1a5bd93..36e074f 100644 --- a/src/pytestqt/logging.py +++ b/src/pytestqt/logging.py @@ -39,7 +39,7 @@ def pytest_runtest_setup(self, item): item.qt_log_capture = _QtMessageCapture(ignore_regexes) item.qt_log_capture._start() - @pytest.mark.hookwrapper + @pytest.hookimpl(hookwrapper=True) def pytest_runtest_makereport(self, item, call): """Add captured Qt messages to test item report if the call failed.""" outcome = yield diff --git a/src/pytestqt/plugin.py b/src/pytestqt/plugin.py index 3be4ccd..fab2c72 100644 --- a/src/pytestqt/plugin.py +++ b/src/pytestqt/plugin.py @@ -157,8 +157,7 @@ def pytest_addoption(parser): ) -@pytest.mark.hookwrapper -@pytest.mark.tryfirst +@pytest.hookimpl(hookwrapper=True, tryfirst=True) def pytest_runtest_setup(item): """ Hook called after before test setup starts, to start capturing exceptions @@ -174,8 +173,7 @@ def pytest_runtest_setup(item): item.qt_exception_capture_manager.fail_if_exceptions_occurred("SETUP") -@pytest.mark.hookwrapper -@pytest.mark.tryfirst +@pytest.hookimpl(hookwrapper=True, tryfirst=True) def pytest_runtest_call(item): yield _process_events() @@ -184,8 +182,7 @@ def pytest_runtest_call(item): item.qt_exception_capture_manager.fail_if_exceptions_occurred("CALL") -@pytest.mark.hookwrapper -@pytest.mark.trylast +@pytest.hookimpl(hookwrapper=True, trylast=True) def pytest_runtest_teardown(item): """ Hook called after each test tear down, to process any pending events and diff --git a/tests/test_logging.py b/tests/test_logging.py index c3d28c5..b13f181 100644 --- a/tests/test_logging.py +++ b/tests/test_logging.py @@ -541,7 +541,7 @@ def test_logging_broken_makereport(testdir): conftest=""" import pytest - @pytest.mark.hookwrapper(tryfirst=True) + @pytest.hookimpl(hookwrapper=True, tryfirst=True) def pytest_runtest_makereport(call): if call.when == 'call': raise Exception("This should not be hidden")