Skip to content

Commit

Permalink
Deprecate _Results.excinfo
Browse files Browse the repository at this point in the history
Resolves pytest-dev#86
  • Loading branch information
Tyler Goodlet committed May 27, 2018
1 parent 76232fa commit aad70f7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
23 changes: 19 additions & 4 deletions pluggy/callers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,28 @@ def __init__(self, result, excinfo):

@property
def excinfo(self):
"""Get the exception info for this hook call (DEPRECATED in favor of
``get_result()``).
"""
warnings.warn(
DeprecationWarning(
'`_Result.excinfo` is deprecated use `get_result()` to raise '
'the underlying exception'),
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'
warnings.warn(DeprecationWarning(msg), stacklevel=2)
"""Get the result(s) for this hook call (DEPRECATED in favor of
``get_result()``).
"""
warnings.warn(
DeprecationWarning(
'`_Result.result` is deprecated use `get_result()` to force '
'correct exception handling'),
stacklevel=2
)
return self._result

@classmethod
Expand All @@ -62,7 +77,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.
Expand Down
2 changes: 1 addition & 1 deletion pluggy/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions testing/test_deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_')
Expand Down

0 comments on commit aad70f7

Please sign in to comment.