[TIP] both naming a parameter and showing its values

Tom Viner tom at viner.tv
Tue Mar 24 16:05:45 PDT 2015


How about using the 3 parametrize arg names (argnames, argvalues, ids) as **
named_args, as in:

def params(n):
    fn = range(n)
    return {'argnames': 'a', 'argvalues': fn, 'ids': ['a: {}'.format(i) for
i in fn]}

named_args = params(3)

@pytest.mark.parametrize(**named_args)
def ...


Date: Mon, 23 Mar 2015 09:43:17 -0400
From: dpb dpb <dpb.mediamath at gmail.com>
Subject: Re: [TIP] both naming a parameter and showing its values
To: testing-in-python at lists.idyll.org
Message-ID:
        <CAJukCzfddgjmDPzp+OVHhXkug_GK2VKi76-oKFi3twiRDjRsaw at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

...
>
> def params(n):
>     fn = range(n)
>     return {'name': 'a', 'args': fn, 'ids': ['a: {}'.format(i) for i in
> fn]}
>
> named_args = params(3)
>
> @pytest.mark.parametrize(
>         named_args['name'], named_args['args'], ids=named_args['ids'])
> def test_funcs_with_naming_func(a):
>     assert a ** 3 == a * (a ** 2)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20150324/e2687469/attachment.htm>


More information about the testing-in-python mailing list