Skip to content

Commit a62cff6

Browse files
author
goodboy
authored
Merge pull request #88 from nicoddemus/deprecate-result
Re-add _Result.result as an attr which triggers a deprecation warning
2 parents 6f28308 + 0d5fd6a commit a62cff6

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

pluggy/callers.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Call loop machinery
33
'''
44
import sys
5-
5+
import warnings
66

77
_py3 = sys.version_info > (3, 0)
88

@@ -33,6 +33,13 @@ def __init__(self, result, excinfo):
3333
def excinfo(self):
3434
return self._excinfo
3535

36+
@property
37+
def result(self):
38+
"""Get the result(s) for this hook call (DEPRECATED in favor of ``get_result()``)."""
39+
msg = 'Use get_result() which forces correct exception handling'
40+
warnings.warn(DeprecationWarning(msg), stacklevel=2)
41+
return self._result
42+
3643
@classmethod
3744
def from_call(cls, func):
3845
__tracebackhide__ = True

testing/test_details.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import warnings
2-
from pluggy import PluginManager, HookimplMarker, HookspecMarker
32

3+
import pytest
4+
5+
from pluggy import PluginManager, HookimplMarker, HookspecMarker, _Result
46

57
hookspec = HookspecMarker("example")
68
hookimpl = HookimplMarker("example")
@@ -93,3 +95,9 @@ def myhook(self, arg1):
9395
warning = warns[-1]
9496
assert issubclass(warning.category, Warning)
9597
assert "Argument(s) ('arg2',)" in str(warning.message)
98+
99+
100+
def test_result_deprecated():
101+
r = _Result(10, None)
102+
with pytest.deprecated_call():
103+
assert r.result == 10

0 commit comments

Comments
 (0)