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

Re-add _Result.result as an attr which triggers a deprecation warning #88

Merged
merged 2 commits into from
Sep 16, 2017
Merged
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
9 changes: 8 additions & 1 deletion pluggy/callers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Call loop machinery
'''
import sys

import warnings

_py3 = sys.version_info > (3, 0)

Expand Down Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion testing/test_details.py
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -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