I have some pytest tests that run a test using a variety of different parameter combinations, like so:
class TestCases:
d_prob = [0.1, 0.8]
f_dens = [0.001, 0.1]
r_scale = [True, False]
i_corr = [True, False]
# Cartesian product
cart = itertools.product(d_prob, f_dens, r_scale, i_corr)
@pytest.fixture(params=cart)
def params(self, request):
return request.param
def test_mytest(self, params):
d, f, r, i = params
# Do stuff...
However, this can quickly blow out into a large number of tests and be pretty slow. So, I would like to have the behaviour change based on whether the slow
mark has been set. I.e. if slow
is set then use the full parameter matrix, otherwise use a reduced set that is faster but less comprehensive.
I’m not sure how to cleanly achieve this though. I am familiar with running tests or not by attaching the slow
mark to them, but I have no idea if I can somehow change my parameter matrix based on such a mark.