-
Notifications
You must be signed in to change notification settings - Fork 124
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
Changes from 4 commits
84fb9ea
428ab80
4cfa3a5
6cf1842
fe2f647
eda95ca
5662715
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,10 +41,21 @@ def from_call(cls, func): | |
return cls(result, excinfo) | ||
|
||
def force_result(self, result): | ||
"""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 | ||
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. Not related to the PR: should we make all attributes private? 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. Hmm yeah maybe? 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. Oh definitely, this wasn't a criticism of the current code, just something I thought I might bring up. If we want to have a well-defined API we might want to start doing that somewhat sooner; a lot of problems of the pytest API stem from the fact that public attributes should never been so, but changing them later is a pain because client code now depends on it (even if by accident). 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. Yeah totally agree. |
||
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 | ||
|
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