Hi Meme, On Thu, Jul 29, 2010 at 18:33 +1000, meme dough wrote: > Hi, > > I was wondering about the pytest_generate_tests which can make many > parameterise test from 1 test function. > > When I have many tests and I want to parameterise a number of them the > pytest_generate_tests function has to have a if metafunc.function == > xxx elif metafunc.function == yyy etc. > > This means a big switch statement on which function it is. It also > means that parameterised data for a function may be a long way from > it. This can happen easy when have a test module per source module. > > Are there any ideas maybe for a pytest_generate_tests for each > function that needs to be parameterised? Maybe like > pytest_generate_tests__myfunc(metafunc) which can create many tests > for the test_myfunc ? > > Just curious if this would be a good idea or not. > > :)
The parametrized testing mechanism is quite low level. As exemplified in http://tetamap.wordpress.com/2009/05/13/ there are various ways to build higher-level parametrized testing. You can e.g. write a generic pytest_generate_tests that invokes a decorator of a test function (or some attribute on its test class) thus allowing very specified and close-to-the-test parametrization. Note: currently pytest_generate_tests cannot easily be combined, i.e. if you have test_func(arg1, arg2) you cannot have two independent pytest_generate_tests method which generate values for each of the args. See also the ISSUES.txt in the repo where there are some notes about parametrized testing. best, holger _______________________________________________ py-dev mailing list py-dev@codespeak.net http://codespeak.net/mailman/listinfo/py-dev