diff --git a/pluggy/callers.py b/pluggy/callers.py index de900d6e..58b47eb5 100644 --- a/pluggy/callers.py +++ b/pluggy/callers.py @@ -2,7 +2,7 @@ Call loop machinery ''' import sys - +import warnings _py3 = sys.version_info > (3, 0) @@ -33,6 +33,13 @@ def __init__(self, result, excinfo): def excinfo(self): return self._excinfo + @property + def result(self): + """Get the result(s) for this hook call (DEPRECATED in favor of ``get_result()``).""" + msg = 'Use get_result() which forces correct exception handling' + warnings.warn(DeprecationWarning(msg), stacklevel=2) + return self._result + @classmethod def from_call(cls, func): __tracebackhide__ = True diff --git a/testing/test_details.py b/testing/test_details.py index e0f3cb9b..2fad198d 100644 --- a/testing/test_details.py +++ b/testing/test_details.py @@ -1,6 +1,8 @@ import warnings -from pluggy import PluginManager, HookimplMarker, HookspecMarker +import pytest + +from pluggy import PluginManager, HookimplMarker, HookspecMarker, _Result hookspec = HookspecMarker("example") hookimpl = HookimplMarker("example") @@ -93,3 +95,9 @@ def myhook(self, arg1): warning = warns[-1] assert issubclass(warning.category, Warning) assert "Argument(s) ('arg2',)" in str(warning.message) + + +def test_result_deprecated(): + r = _Result(10, None) + with pytest.deprecated_call(): + assert r.result == 10