Skip to content

Commit

Permalink
Merge pull request #88 from nicoddemus/deprecate-result
Browse files Browse the repository at this point in the history
Re-add _Result.result as an attr which triggers a deprecation warning
  • Loading branch information
goodboy committed Sep 16, 2017
2 parents 6f28308 + 0d5fd6a commit a62cff6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
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

0 comments on commit a62cff6

Please sign in to comment.