diff --git a/pluggy/callers.py b/pluggy/callers.py index 3ff67bec..edbf1a44 100644 --- a/pluggy/callers.py +++ b/pluggy/callers.py @@ -31,12 +31,17 @@ def __init__(self, result, excinfo): @property def excinfo(self): + """Get the exception info for this hook call (DEPRECATED in favor of + ``get_result()``). + """ + msg = 'Use `get_result()` which raises the underlying exception' + warnings.warn(DeprecationWarning(msg), stacklevel=2) 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' + msg = 'Use `get_result()` which forces correct exception handling' warnings.warn(DeprecationWarning(msg), stacklevel=2) return self._result @@ -62,7 +67,7 @@ def force_result(self, result): self._excinfo = None def get_result(self): - """Get the result(s) for this hook call. + """Get the result(s) for this hook call; raises any caught exception. If the hook was marked as a ``firstresult`` only a single value will be returned otherwise a list of results. diff --git a/pluggy/manager.py b/pluggy/manager.py index bc0ea608..f39e06bb 100644 --- a/pluggy/manager.py +++ b/pluggy/manager.py @@ -297,7 +297,7 @@ def before(hook_name, methods, kwargs): hooktrace(hook_name, kwargs) def after(outcome, hook_name, methods, kwargs): - if outcome.excinfo is None: + if outcome._excinfo is None: hooktrace("finish", hook_name, "-->", outcome.get_result()) hooktrace.root.indent -= 1 diff --git a/testing/test_deprecations.py b/testing/test_deprecations.py index 3000a374..27e19eb4 100644 --- a/testing/test_deprecations.py +++ b/testing/test_deprecations.py @@ -15,6 +15,17 @@ def test_result_deprecated(): assert r.result == 10 +def test_excinfo_deprecated(): + + def err(): + raise RuntimeError + + r = _Result.from_call(err) + + with pytest.deprecated_call(): + assert r.excinfo == r._excinfo + + def test_implprefix_deprecated(): with pytest.deprecated_call(): pm = PluginManager('blah', implprefix='blah_')