2 new commits in pytest: https://bitbucket.org/pytest-dev/pytest/commits/88a5fdc86c08/ Changeset: 88a5fdc86c08 Branch: yield-experimental-docs User: nicoddemus Date: 2015-04-03 19:55:10+00:00 Summary: Reviewed wording about yield being a "new" feature Affected #: 1 file
diff -r 60008bd048a58852c513d129a0b8093cb9fc552b -r 88a5fdc86c0871498a95e33fa8c50e66416f3fef doc/en/yieldfixture.txt --- a/doc/en/yieldfixture.txt +++ b/doc/en/yieldfixture.txt @@ -11,7 +11,7 @@ of a ``return`` statement to provide a fixture value while otherwise fully supporting all other fixture features. -Let's look at a simple standalone-example using the new ``yield`` syntax:: +Let's look at a simple standalone-example using the ``yield`` syntax:: # content of test_yield.py @@ -64,9 +64,9 @@ because the Python ``file`` object supports finalization when the ``with`` statement ends. -Note that the new syntax is fully integrated with using ``scope``, -``params`` and other fixture features. Changing existing -fixture functions to use ``yield`` is thus straight forward. +Note that the yield fixture form supports all other fixture +features such as ``scope``, ``params``, etc., thus changing existing +fixture functions to use ``yield`` is straight forward. Discussion and future considerations / feedback ++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -106,7 +106,7 @@ - lastly ``yield`` introduces more than one way to write fixture functions, so what's the obvious way to a newcomer? Newcomers reading the docs will see feature examples using the - ``return`` style so should use that, if in doubt. + ``return`` style so should use that, if in doubt. Others can start experimenting with writing yield-style fixtures and possibly help evolving them further. https://bitbucket.org/pytest-dev/pytest/commits/619ad0c4b4dc/ Changeset: 619ad0c4b4dc Branch: yield-experimental-docs User: nicoddemus Date: 2015-04-03 19:59:33+00:00 Summary: Removed "discussion" session Kept a note about exceptions after yield not being reraised Affected #: 1 file diff -r 88a5fdc86c0871498a95e33fa8c50e66416f3fef -r 619ad0c4b4dc6e18a088c058f44aa00c7fc60f9f doc/en/yieldfixture.txt --- a/doc/en/yieldfixture.txt +++ b/doc/en/yieldfixture.txt @@ -68,48 +68,13 @@ features such as ``scope``, ``params``, etc., thus changing existing fixture functions to use ``yield`` is straight forward. -Discussion and future considerations / feedback -++++++++++++++++++++++++++++++++++++++++++++++++++++ +.. note:: -The yield-syntax has been discussed by pytest users extensively. -In general, the advantages of the using a ``yield`` fixture syntax are: + While the ``yield`` syntax is similar to what + :py:func:`contextlib.contextmanager` decorated functions + provide, with pytest fixture functions the part after the + "yield" will always be invoked, independently from the + exception status of the test function which uses the fixture. + This behaviour makes sense if you consider that many different + test functions might use a module or session scoped fixture. -- easy provision of fixtures in conjunction with context managers. - -- no need to register a callback, providing for more synchronous - control flow in the fixture function. Also there is no need to accept - the ``request`` object into the fixture function just for providing - finalization code. - -However, there are also limitations or foreseeable irritations: - -- usually ``yield`` is used for producing multiple values. - But fixture functions can only yield exactly one value. - Yielding a second fixture value will get you an error. - It's possible we can evolve pytest to allow for producing - multiple values as an alternative to current parametrization. - For now, you can just use the normal - :ref:`fixture parametrization <fixture-parametrize>` - mechanisms together with ``yield``-style fixtures. - -- the ``yield`` syntax is similar to what - :py:func:`contextlib.contextmanager` decorated functions - provide. With pytest fixture functions, the "after yield" part will - always be invoked, independently from the exception status - of the test function which uses the fixture. The pytest - behaviour makes sense if you consider that many different - test functions might use a module or session scoped fixture. - Some test functions might raise exceptions and others not, - so how could pytest re-raise a single exception at the - ``yield`` point in the fixture function? - -- lastly ``yield`` introduces more than one way to write - fixture functions, so what's the obvious way to a newcomer? - Newcomers reading the docs will see feature examples using the - ``return`` style so should use that, if in doubt. - Others can start experimenting with writing yield-style fixtures - and possibly help evolving them further. - -If you want to feedback or participate in the ongoing -discussion, please join our :ref:`contact channels`. -you are most welcome. Repository URL: https://bitbucket.org/pytest-dev/pytest/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. _______________________________________________ pytest-commit mailing list pytest-commit@python.org https://mail.python.org/mailman/listinfo/pytest-commit