From 0fa215343a44fd51739f051301611352e7e69168 Mon Sep 17 00:00:00 2001 From: Anat Wax Date: Mon, 1 Jun 2026 14:34:32 +0300 Subject: [PATCH] infra: Scope incremental cascade per parameter set When an incremental class is parametrized at class level, a failure in one parameter set (e.g. ipv4) should not cascade into another (e.g. ipv6) since they are independent test cycles. Assisted-by: Claude Signed-off-by: Anat Wax --- conftest.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/conftest.py b/conftest.py index 2387199374..eafa111f9d 100644 --- a/conftest.py +++ b/conftest.py @@ -676,7 +676,10 @@ def pytest_runtest_makereport(item, call): """ if call.excinfo is not None and "incremental" in item.keywords: parent = item.parent - parent._previousfailed = item + param_key = item.callspec.id if hasattr(item, "callspec") else "" + if not hasattr(parent, "_previousfailed"): + parent._previousfailed = {} + parent._previousfailed[param_key] = item outcome = yield report = outcome.get_result() @@ -732,7 +735,8 @@ def pytest_runtest_setup(item): BASIC_LOGGER.info(f"\n{separator(symbol_='-', val=item.name)}") BASIC_LOGGER.info(f"{separator(symbol_='-', val='SETUP')}") if "incremental" in item.keywords: - previousfailed = getattr(item.parent, "_previousfailed", None) + param_key = item.callspec.id if hasattr(item, "callspec") else "" + previousfailed = getattr(item.parent, "_previousfailed", {}).get(param_key) if previousfailed is not None: pytest.xfail("previous test failed (%s)" % previousfailed.name)