-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Make normal fixtures work with "yield" #1586
Make normal fixtures work with "yield" #1586
Conversation
(quick note: AppVeyor is failing because of the "doctesting" env, which is already fixed in master) |
Looks neat, surprisingly simple, just wondering if this is to be considered a breaking api change art semver |
@@ -2326,6 +2326,7 @@ def fail_fixturefunc(fixturefunc, msg): | |||
pytrace=False) | |||
|
|||
def call_fixture_func(fixturefunc, request, kwargs, yieldctx): | |||
yieldctx = is_generator(fixturefunc) | |||
if yieldctx: | |||
if not is_generator(fixturefunc): | |||
fail_fixturefunc(fixturefunc, |
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.
So I know this is a WIP, just adding this so we don't accidentally forget: Those lines aren't needed anymore now 😉
EDIT: Or should be changed to work again, as I pointed out in #1586 (comment)
Awesome! 👍 @RonnyPfannschmidt What would be the breaking change? I can only imagine two things:
|
@The-Compiler true |
Nice, I will continue to work on the PR then (clean it up and docs, mostly). About the documentation, I plan to consider
I see. We just have to consider that to keep this behavior we need to keep |
Sounds great to me!
Hmm, that's a good point. On a second thought I guess we can do without it, as hopefully people will get away from using |
a0bbad6
to
a91d035
Compare
Cleaned up the code and updated docs! 😁 |
@@ -211,7 +211,7 @@ but here is a simple overview: | |||
You need to have Python 2.7 and 3.5 available in your system. Now | |||
running tests is as simple as issuing this command:: | |||
|
|||
$ python runtox.py -e linting,py27,py35 | |||
$ python3 runtox.py -e linting,py27,py35 |
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.
This change is already on master
, cherry-picked here to see green builds. 😁
e2040f4
to
bdc2996
Compare
Guys, would you like to merge this now or would you rather wait until the sprint? |
I'm a bit late to the party, but LGTM, and thanks for the great work! I think this definitely simplifies things a lot. 👍 |
In pytest-dev/pytest#1586 the "yieldctx" argument to FixtureDef was removed. This uses utils.get_args to check if it's needed or not so pytest-bdd works on pytest versions before and after that PR.
Did a quick experiment to see how hard would it be to implement #1461 to suggest working on it during the sprint... astonished to find out it was way too easy. 😲
Just ignore the
yieldctx
parameter and decide on the spot if we are a "yield fixture" based on whether or not the function is a generator does the trick nicely.Almost all of the changes are related only to change the tests of
yield_fixture
to also test with plainfixture
to prove this is working.Missing:
yieldctx
around);Opening the PR to discuss if we should move this forward or not. @RonnyPfannschmidt, @hpk42, @The-Compiler what you guys think?