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 24, 2018
1 parent 76232fa commit cd6b8fa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
9 changes: 7 additions & 2 deletions pluggy/callers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
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 cd6b8fa

Please sign in to comment.