-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
Using Python 2.7.12
and pytest 3.0.6
Sometimes I parameterize test cases with arguments via argvalues=itertools.product(..., ..., etc.)
. I'd like to be able to label the parameterized test cases but treat each argument a bit differently based on type. From the parametrize
docstring, I was a bit confused whether the intent was to have the callable operate on a single element of an argval tuple, or the entire tuple. Just anecdotally, it seems like the ids
customization is operating on one element of the argument value tuple rather than on the entire tuple, prohibiting the position-(type-)dependent behavior that I'd like when using a callable as the argument to ids
. I can work around this by putting some type-indicative conditional logic in the callable that I pass to operate on a single tuple element, or just build up a list of string ids
instead, but I'd like a cleaner callable route if possible. I'm wondering if I'm making a mistake in how I'm using this feature, or whether this is something that isn't currently supported.
import itertools
import pytest
def df1():
return
def df2():
return
@pytest.mark.parametrize(argnames="func,text",
argvalues=itertools.product([df1, df2],
["first", "second"]),
ids=lambda args: "{}:{}".format(args[0].__name__,
args[1]))
def test_ids(func, text):
pass