[TIP] yield-tests and fixtures: should they have a future?

holger krekel holger at merlinux.eu
Fri Dec 21 01:51:03 PST 2012

Hi testing folks, hi Jason,

i am looking at some recent pytest issues and would like to simplify
pytest's internal fixture handling.  One obstacle/complication are
yield-tests, i.e. the style of producing tests with a generator::

    def test_gen(self):
        for x in range(10):
            yield check, x
This currently produces 10 test items, calling the "check" function with the
respective parameter.  This by itself is not a big deal to support.
However, some people expect fixtures/setup_function/method functions to execute
before the generator does and this mixes the collection with the runtest phase.
Unfortunately, nose also supports this notion although i am wondering how
nose2 is going to deal with it as Jason also plans to separate collection
from running.

So i am thinking about dropping fixture/setup support for yield-tests in pytest
but OTOH i'd like to keep backward and nose compatibility.  As far as pytest
is concerned, it has many others means of parametrization independently
from yield, see e. g. http://pytest.org/latest/fixture.html#fixture-parametrize
and http://pytest.org/latest/parametrize.html and more and more people 
are starting to use those (pytest does not document or recommend yield
for 1-2 years now).

If anyone has any input/thoughts on this, please shoot.


More information about the testing-in-python mailing list