Skip test_warning_captured_deprecated_in_pytest_6 in pytest>=7.1
This commit is contained in:
@@ -294,6 +294,8 @@ class DSession:
|
|||||||
|
|
||||||
def worker_warning_captured(self, warning_message, when, item):
|
def worker_warning_captured(self, warning_message, when, item):
|
||||||
"""Emitted when a node calls the pytest_warning_captured hook (deprecated in 6.0)."""
|
"""Emitted when a node calls the pytest_warning_captured hook (deprecated in 6.0)."""
|
||||||
|
# This hook as been removed in pytest 7.1, and we can remove support once we only
|
||||||
|
# support pytest >=7.1.
|
||||||
kwargs = dict(warning_message=warning_message, when=when, item=item)
|
kwargs = dict(warning_message=warning_message, when=when, item=item)
|
||||||
self.config.hook.pytest_warning_captured.call_historic(kwargs=kwargs)
|
self.config.hook.pytest_warning_captured.call_historic(kwargs=kwargs)
|
||||||
|
|
||||||
|
|||||||
@@ -773,6 +773,13 @@ class TestWarnings:
|
|||||||
"""
|
"""
|
||||||
Do not trigger the deprecated pytest_warning_captured hook in pytest 6+ (#562)
|
Do not trigger the deprecated pytest_warning_captured hook in pytest 6+ (#562)
|
||||||
"""
|
"""
|
||||||
|
from _pytest import hookspec
|
||||||
|
|
||||||
|
if not hasattr(hookspec, "pytest_warning_captured"):
|
||||||
|
pytest.skip(
|
||||||
|
f"pytest {pytest.__version__} does not have the pytest_warning_captured hook."
|
||||||
|
)
|
||||||
|
|
||||||
pytester.makeconftest(
|
pytester.makeconftest(
|
||||||
"""
|
"""
|
||||||
def pytest_warning_captured(warning_message):
|
def pytest_warning_captured(warning_message):
|
||||||
|
|||||||
Reference in New Issue
Block a user