Skip to content

Commit

Permalink
Use pytest.hookimpl
Browse files Browse the repository at this point in the history
  • Loading branch information
The-Compiler committed Oct 6, 2022
1 parent 1306376 commit 65ab139
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
3 changes: 3 additions & 0 deletions 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)
------------------

Expand Down
2 changes: 1 addition & 1 deletion src/pytestqt/logging.py
Expand Up @@ -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
Expand Down
9 changes: 3 additions & 6 deletions src/pytestqt/plugin.py
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_logging.py
Expand Up @@ -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")
Expand Down

0 comments on commit 65ab139

Please sign in to comment.