-
Notifications
You must be signed in to change notification settings - Fork 121
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
Some outstanding docs #85
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
84fb9ea
Add a plugin call-order test
428ab80
Document LIFO hook ordering by plugin registration
4cfa3a5
Document the public `_Result` API methods
6cf1842
Add note about LIFO order for try[first/last] hooks
fe2f647
Make internal `_Result` attrs private
eda95ca
Flip to next dev patch release
5662715
Keep `_Result.excinfo` public; pytest relies on it
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,12 @@ class HookCallError(Exception): | |
|
||
class _Result(object): | ||
def __init__(self, result, excinfo): | ||
self.result = result | ||
self.excinfo = excinfo | ||
self._result = result | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just noticed that this broke some tests in pytest, so pytest-dev/pytest#2744 is already paying off. 👍 |
||
self._excinfo = excinfo | ||
|
||
@property | ||
def excinfo(self): | ||
return self._excinfo | ||
|
||
@classmethod | ||
def from_call(cls, func): | ||
|
@@ -41,15 +45,26 @@ def from_call(cls, func): | |
return cls(result, excinfo) | ||
|
||
def force_result(self, result): | ||
self.result = result | ||
self.excinfo = None | ||
"""Force the result(s) to ``result``. | ||
|
||
If the hook was marked as a ``firstresult`` a single value should | ||
be set otherwise set a (modified) list of results. Any exceptions | ||
found during invocation will be deleted. | ||
""" | ||
self._result = result | ||
self._excinfo = None | ||
|
||
def get_result(self): | ||
"""Get the result(s) for this hook call. | ||
|
||
If the hook was marked as a ``firstresult`` only a single value | ||
will be returned otherwise a list of results. | ||
""" | ||
__tracebackhide__ = True | ||
if self.excinfo is None: | ||
return self.result | ||
if self._excinfo is None: | ||
return self._result | ||
else: | ||
ex = self.excinfo | ||
ex = self._excinfo | ||
if _py3: | ||
raise ex[1].with_traceback(ex[2]) | ||
_reraise(*ex) # noqa | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when more than one hookimpl are marked as
tryfirst
ortrylast
? I believe then LIFO registered order for them applies, but perhaps this should be explicitly mentioned.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so something like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done