Skip to content
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

Merged
merged 4 commits into from
Aug 30, 2017
Merged

Conversation

goodboy
Copy link
Contributor

@goodboy goodboy commented Aug 30, 2017

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...

Tyler Goodlet added 2 commits August 30, 2017 14:43
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):
Copy link
Member

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.

Copy link
Contributor Author

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.

@nicoddemus
Copy link
Member

Sorry about the delay...

Not at all, thanks for tackling this so quickly.

@@ -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
Copy link
Member

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)

Copy link
Contributor Author

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 👍

Tyler Goodlet added 2 commits August 30, 2017 16:17
Avoids forcing a result with `firstresult` hooks.
Thanks to @RonnyPfannschmidt for the nice simplification.
@goodboy
Copy link
Contributor Author

goodboy commented Aug 30, 2017

@RonnyPfannschmidt added your cleaner code.
@nicoddemus added the force result test.

Let me know if we need more.

@nicoddemus
Copy link
Member

Tested with pytest and after a few tweaks (__multicall__ issues a warning and pytest is configured to treat warnings as errors) everything seems fine. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants