Skip to content

Commit fc47e84

Browse files
authored
Merge pull request #455 from The-Compiler/new-hookimpl
2 parents 1306376 + 65ab139 commit fc47e84

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
UNRELEASED
22
----------
33

4+
- Use ``pytest.hookimpl`` to configure hooks, avoiding a deprecation warning in
5+
the upcoming pytest 7.2.0.
6+
47
4.1.0 (2022-06-23)
58
------------------
69

src/pytestqt/logging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def pytest_runtest_setup(self, item):
3939
item.qt_log_capture = _QtMessageCapture(ignore_regexes)
4040
item.qt_log_capture._start()
4141

42-
@pytest.mark.hookwrapper
42+
@pytest.hookimpl(hookwrapper=True)
4343
def pytest_runtest_makereport(self, item, call):
4444
"""Add captured Qt messages to test item report if the call failed."""
4545
outcome = yield

src/pytestqt/plugin.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ def pytest_addoption(parser):
157157
)
158158

159159

160-
@pytest.mark.hookwrapper
161-
@pytest.mark.tryfirst
160+
@pytest.hookimpl(hookwrapper=True, tryfirst=True)
162161
def pytest_runtest_setup(item):
163162
"""
164163
Hook called after before test setup starts, to start capturing exceptions
@@ -174,8 +173,7 @@ def pytest_runtest_setup(item):
174173
item.qt_exception_capture_manager.fail_if_exceptions_occurred("SETUP")
175174

176175

177-
@pytest.mark.hookwrapper
178-
@pytest.mark.tryfirst
176+
@pytest.hookimpl(hookwrapper=True, tryfirst=True)
179177
def pytest_runtest_call(item):
180178
yield
181179
_process_events()
@@ -184,8 +182,7 @@ def pytest_runtest_call(item):
184182
item.qt_exception_capture_manager.fail_if_exceptions_occurred("CALL")
185183

186184

187-
@pytest.mark.hookwrapper
188-
@pytest.mark.trylast
185+
@pytest.hookimpl(hookwrapper=True, trylast=True)
189186
def pytest_runtest_teardown(item):
190187
"""
191188
Hook called after each test tear down, to process any pending events and

tests/test_logging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ def test_logging_broken_makereport(testdir):
541541
conftest="""
542542
import pytest
543543
544-
@pytest.mark.hookwrapper(tryfirst=True)
544+
@pytest.hookimpl(hookwrapper=True, tryfirst=True)
545545
def pytest_runtest_makereport(call):
546546
if call.when == 'call':
547547
raise Exception("This should not be hidden")

0 commit comments

Comments
 (0)