[issue7897] Support parametrized tests in unittest

Fernando Perez report at bugs.python.org
Fri Apr 9 21:25:47 CEST 2010


Fernando Perez <fdo.perez at gmail.com> added the comment:

Hey Yarick,

On Thu, Apr 8, 2010 at 18:53, Yaroslav Halchenko <report at bugs.python.org> w=
rote:
> In PyMVPA we have our little decorator as an alternative to Fernando's ge=
nerators, =A0and which is closer, I think, to what Michael was wishing for:
> @sweepargs
>
> http://github.com/yarikoptic/PyMVPA/blob/master/mvpa/testing/sweepargs.py
>
> NB it has some minor PyMVPA specificity which could be easily wiped out, =
and since it was at most 4 eyes looking at it and it bears "evolutionary" c=
hanges, it is far from being the cleanest/best piece of code, BUT:
>
> * it is very easy to use, just decorate a test method/function and give a=
n argument which to vary within the function call, e.g smth like
>
> @sweepargs(arg=3Drange(5))
> def test_sweepargs_demo(arg):
> =A0 =A0ok_(arg < 5)
> =A0 =A0ok_(arg < 3)
> =A0 =A0ok_(arg < 2)
>
> For nose/unittest it would still look like a single test

Thanks for the post; I obviously defer to Michael on the final
decision, but I *really* would like a solution that reports an
'argument sweep' as multiple tests, not as one.  They are truly
multiple tests (since they can pass/fail independently), so I think
they should be treated as such.

On the other hand, your code does have nifty features that could be
used as well, so perhaps the best of both can be used in the end.

Cheers,

f

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7897>
_______________________________________


More information about the Python-bugs-list mailing list