Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate _Result.excinfo #155

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/155.removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deprecate ``_Result.excinfo`` in favor of ``_Result.get_result()``.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a D here 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait what?

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
6 changes: 6 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[pytest]
filterwarnings =
once::DeprecationWarning
once::PendingDeprecationWarning
ignore:::pluggy

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