-
Notifications
You must be signed in to change notification settings - Fork 123
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
Firstresult madness #72
Conversation
This is to expose the regression from issue pytest-dev#71. Wrappers must return a single value not a list.
Ensures that wrappers receive a single value instead of a list. Fixes pytest-dev#71
@@ -87,9 +87,17 @@ class Plugin3(object): | |||
def hello(self, arg): | |||
return None | |||
|
|||
class Plugin4(object): |
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.
Perhaps we should add a new test which also changes the outcome
result to make sure?
I plan to test this branch in pytest later today as well.
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.
@nicoddemus yes good call.
I'll add a force result test.
Not at all, thanks for tackling this so quickly. |
pluggy/callers.py
Outdated
@@ -97,6 +97,10 @@ def execute(self): | |||
excinfo = sys.exc_info() | |||
finally: | |||
outcome = _Result(results, excinfo) | |||
if firstresult: # first result hooks return a single value |
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.
i believe it would be more clear to construct the result differently in the firstresult case
if firstresult:
outcome = _Result(results[0] if results else None, excinfo)
else:
outcome = _Result(results, excinfo)
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.
thanks ronny that's way cleaner 👍
Avoids forcing a result with `firstresult` hooks. Thanks to @RonnyPfannschmidt for the nice simplification.
@RonnyPfannschmidt added your cleaner code. Let me know if we need more. |
Tested with |
I think this best solves pytest-dev/pytest#2730 and #71 and is pretty clear.
I'm of course open to a better way if you guys think of one.
Sorry about the delay...