Skip to content

Commit fdd7e83

Browse files
committed
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 <noreply@anthropic.com> Signed-off-by: Anat Wax <awax@redhat.com>
1 parent e203b75 commit fdd7e83

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

conftest.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,14 +669,22 @@ def pytest_report_teststatus(report, config):
669669
return None
670670

671671

672+
def _get_incremental_param_key(item: pytest.Item) -> str:
673+
if match := re.search(r"\[(.+)\]$", item.name):
674+
return match.group(1)
675+
return ""
676+
677+
672678
@pytest.hookimpl(hookwrapper=True)
673679
def pytest_runtest_makereport(item, call):
674680
"""
675681
incremental tests implementation
676682
"""
677683
if call.excinfo is not None and "incremental" in item.keywords:
678684
parent = item.parent
679-
parent._previousfailed = item
685+
if not hasattr(parent, "_previousfailed"):
686+
parent._previousfailed = {}
687+
parent._previousfailed[_get_incremental_param_key(item)] = item
680688

681689
outcome = yield
682690
report = outcome.get_result()
@@ -732,7 +740,7 @@ def pytest_runtest_setup(item):
732740
BASIC_LOGGER.info(f"\n{separator(symbol_='-', val=item.name)}")
733741
BASIC_LOGGER.info(f"{separator(symbol_='-', val='SETUP')}")
734742
if "incremental" in item.keywords:
735-
previousfailed = getattr(item.parent, "_previousfailed", None)
743+
previousfailed = getattr(item.parent, "_previousfailed", {}).get(_get_incremental_param_key(item))
736744
if previousfailed is not None:
737745
pytest.xfail("previous test failed (%s)" % previousfailed.name)
738746

0 commit comments

Comments
 (0)