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

Use pytest.hookimpl #455

Merged
merged 1 commit into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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