diff --git a/tests/test_param.py b/tests/test_param.py index bc423a40..b0f2438b 100644 --- a/tests/test_param.py +++ b/tests/test_param.py @@ -41,4 +41,32 @@ testdata = [ @pytest.mark.parametrize("a,b,expected", testdata) def test_timedistance_v1(a, b, expected): diff = a - b - assert diff == expected \ No newline at end of file + assert diff == expected + + +scenarios = [ + ("one", {"x": 1, "y": 2}), + ("two", {"x": 3, "y": 4}), + ("edge", {"x": -1, "y": -1}), +] + +def pytest_generate_tests(metafunc): + if hasattr(metafunc.cls, "scenarios"): + ids = [] + argnames = [] + argvalues = [] + + for name, param_dict in metafunc.cls.scenarios: + ids.append(name) + if not argnames: + argnames = list(param_dict.keys()) + argvalues.append([param_dict[k] for k in argnames]) + + metafunc.parametrize(argnames, argvalues, ids=ids) + + +class TestDynamic: + scenarios = scenarios + + def test_sum_positive(self, x, y): + assert (x + y) >= 0 \ No newline at end of file