-
-
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
Suggestion: merge .fixture and .yield_fixture #1461
Comments
Particularly I agree that I don't think there are backward compatibility issues, because we can use But I would like to hear what others have to say on this. |
I've always thought the same, but I thought there was some obscure reason it was done the way it is rather than combining them since the beginning - seems like I'm wrong? 😉 I've also talked with @hpk42 about yield-fixtures vs. normal fixtures, in the context of the pytest trainings we're giving. He finds it more difficult to teach the I personally think it's still easier to teach than If I were to decide, I'd integrate |
👍
Depends on what you mean exactly by deprecate, but I would prefer just discourage or note that |
we need a proper deprecation warning system |
I agree, but do you feel the need for a better warning system blocks deprecating |
As an experienced Python developer learning pytest, having the two merged together would have reduced what I had to learn with pytest. Also, I'm pretty sure I'll forget (and need to lookup in the doc) the specific name |
Resolved in #1586 |
I do enjoy open source software :). On Thursday, June 16, 2016, Bruno Oliveira notifications@github.com wrote:
|
The yield_fixture page says:
My suggestion is to merge
pytest.fixture
andpytest.yield_fixture
.Before:
After:
This should be possible - if calling the fixture function returns a generator, then do what
yield_fixture
currently does, otherwise (i.e. if it returns a value), then do whatfixture
currently does.The reason? There will be one less choice for a newcomer to make - which decorator to call.
Further, the documentation section "Fixture finalization / executing teardown code" can now read something like this:
This is a straightforward change, syntactically (
return
->yield
), even if the internals are quite different, and is intuitive enough to me, and I suspect anyone who gets how generators work.I suggest deprecating the old callback-teardown method since the
yield
mechanism is superior in every way. Really it should be the only way, but it may be confusing to someone who expects to be able to simply return a value, and so returning a value will just work as well.The text was updated successfully, but these errors were encountered: