From 79b5922a2b8a13fd292ef6fe6e7c04e2c603802b Mon Sep 17 00:00:00 2001 From: tligui_y Date: Thu, 17 Jul 2025 10:15:48 +0200 Subject: [PATCH] Update tests/test_param.py --- tests/test_param.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) 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