pytest.mark.parametrize on multiple fixtures #11375
-
A little bit of demo code showing three different version of the same test. No idea if this a bug or an unsupported feature. It would be handy to be able to use also v2 version of the test. from itertools import product
import pytest
COUNTRIES = [("Italy", "IT"), ("Germany", "DE")]
DISHES = [("Caprese Salad", "CS"), ("Sauerkraut", "SK")]
COUNTRY_PARAMS = [pytest.param(country, id=id) for country, id in COUNTRIES]
DISH_PARAMS = [pytest.param(dish, id=id) for dish, id in DISHES]
COUNTRY_DISH_PARAMS = [
pytest.param(country, dish, id=f"{country_id}-{dish_id}")
for (country, country_id), (dish, dish_id) in product(COUNTRIES, DISHES)
]
@pytest.mark.parametrize("country", COUNTRY_PARAMS)
@pytest.mark.parametrize("dish", DISH_PARAMS)
def test_dish_v0(country, dish):
print(f"Eat {dish} in {country}")
@pytest.mark.parametrize("country,dish", COUNTRY_DISH_PARAMS)
def test_dish_v2(country, dish):
print(f"Eat {dish} in {country}")
@pytest.mark.parametrize("country,dish", product(COUNTRY_PARAMS, DISH_PARAMS))
def test_dish_v3(country, dish):
print(f"Eat {dish} in {country}")
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
currently this is intentionally not supported, im -1 on adding support as in practice it means aritrary nesting of a intentionally not nested marker structure we might however consider adding support for the + operator of parameterset |
Beta Was this translation helpful? Give feedback.
currently this is intentionally not supported, im -1 on adding support as in practice it means aritrary nesting of a intentionally not nested marker structure
we might however consider adding support for the + operator of parameterset