Skip to content

Commit 7e88700

Browse files
AnatwOhadRevah
authored andcommitted
infra: Scope incremental cascade per parameter set (RedHatQE#5086)
##### What this PR does / why we need it: 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 with fresh fixtures. This was discovered while working on PR RedHatQE#5026 — adding `@pytest.mark.jira("CNV-88755", run=False)` to a single test caused 6 xfails instead of just 2 skips, because `_previousfailed` is stored on the class node which is shared across all parametrize combinations. ##### Which issue(s) this PR fixes: ##### Special notes for reviewer: - Non-parametrized incremental classes are unaffected — all their tests share the same key so behavior is identical to before. - Currently two incremental classes use class-level parametrize: - `tests/network/l2_bridge/migration_stuntime/test_migration_stuntime.py` - `tests/network/localnet/migration_stuntime/test_migration_stuntime.py` ##### jira-ticket: <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Improved incremental test failure tracking for parametrized tests, so failures are tracked per-parameter set—leading to clearer xfail attribution and more reliable test outcomes. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Anat Wax <awax@redhat.com>
1 parent 8e1fb20 commit 7e88700

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

conftest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,10 @@ def pytest_runtest_makereport(item, call):
676676
"""
677677
if call.excinfo is not None and "incremental" in item.keywords:
678678
parent = item.parent
679-
parent._previousfailed = item
679+
param_key = item.callspec.id if hasattr(item, "callspec") else ""
680+
if not hasattr(parent, "_previousfailed"):
681+
parent._previousfailed = {}
682+
parent._previousfailed[param_key] = item
680683

681684
outcome = yield
682685
report = outcome.get_result()
@@ -732,7 +735,8 @@ def pytest_runtest_setup(item):
732735
BASIC_LOGGER.info(f"\n{separator(symbol_='-', val=item.name)}")
733736
BASIC_LOGGER.info(f"{separator(symbol_='-', val='SETUP')}")
734737
if "incremental" in item.keywords:
735-
previousfailed = getattr(item.parent, "_previousfailed", None)
738+
param_key = item.callspec.id if hasattr(item, "callspec") else ""
739+
previousfailed = getattr(item.parent, "_previousfailed", {}).get(param_key)
736740
if previousfailed is not None:
737741
pytest.xfail(f"previous test failed ({previousfailed.name})")
738742

0 commit comments

Comments
 (0)