[py-dev] new parametrized tests / deprecating yield

Sridhar Ratnakumar sridharr at activestate.com
Fri May 22 00:29:35 CEST 2009

 > holger: [...] The new way to parametrize test is meant to substitute
 > yield usage of test-functions aka "generative tests", also used by
 > nosetests. yield-style Generative tests have received criticism and
 > despite being the one who invented them, i mostly agree and recommend
 > not using them anymore.

I use `yield' to run 'sub-tests' in sequential order. For example, in 
this particular usecase:


You'll notice I have to run test_install, test_list_all, test_import, 
test_remove in that *order*.

It is not possible to make them methods of a class and use 
`pytest_generate_tests' to run them in sequential order because each of 
these sub-tests, besides the order, also depend on their position of 
execution (i.e., test_search is to be run after the statement 
``c.do_update(None, None, repo_root_url)``)

`yield' achieves this elegantly; I don't know how one would achieve this 
requirement otherwise.

BTW, there is no way for me to use funcargs in yield based tests (which 
is why I'm calling the setup function, `prepare_client', manually).


On 09-05-13 11:19 AM, holger krekel wrote:
> Hi folks,
> for those not following my blog, here is my post
> about the newstyle generative tests which are
> to substitute and improve on "yield" based tests,
> among other parametrization methods:
>      http://tetamap.wordpress.com/2009/05/13/parametrizing
> Hope to get another py.test beta out next week that would
> contain this.  I am still set to finish refining and
> documenting extension hooks ... the above was part of that
> effort although i originally planned the "parametrizing" hook
> as a post 1.0 feature.
> Anyway, let me know what you think - there is still time to do
> some adjustments or changes especially to funcargs.
> cheers,
> holger

More information about the Pytest-dev mailing list