From 8724ffec97851a6359cef16d64b94ebc8a106e32 Mon Sep 17 00:00:00 2001 From: nhegde-microsoft Date: Wed, 22 Jul 2026 13:32:05 +1000 Subject: [PATCH] [conditional_mark] Backport nodeid normalization to 202605 Backport #25930 so conditional marks match tests/-relative keys when pytest resolves rootdir above the tests directory. This is required for the warm-reboot skips in #26417 to apply under the standard run_tests.sh invocation. (cherry picked from commit 3cf07f4b6bf3a57037ae4b7310805284049f0b64) Signed-off-by: Nikhil Hegde Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b8fb8259-87f3-4de3-b1a4-59fe52e8be86 Signed-off-by: Xichen96 --- tests/common/plugins/conditional_mark/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/common/plugins/conditional_mark/__init__.py b/tests/common/plugins/conditional_mark/__init__.py index abf9d7383f8..27df84d999a 100644 --- a/tests/common/plugins/conditional_mark/__init__.py +++ b/tests/common/plugins/conditional_mark/__init__.py @@ -710,12 +710,16 @@ def pytest_collection_modifyitems(session, config, items): json.dumps(basic_facts, indent=2))) dynamic_update_skip_reason = session.config.option.dynamic_update_skip_reason basic_facts['constants'] = MARK_CONDITIONS_CONSTANTS - # Normalize nodeids: strip root directory prefix if present (pytest 9.0+ includes it) + # Normalize nodeids to match the tests/-relative condition keys. rootdir may + # float above tests/ (e.g. --inventory ../ansible/veos_vtb), so strip both + # basename(rootpath) and a leading "tests/" or all conditional skips no-op. root_prefix = os.path.basename(str(session.config.rootpath)) + "/" for item in items: nodeid = item.nodeid if nodeid.startswith(root_prefix): nodeid = nodeid[len(root_prefix):] + if nodeid.startswith("tests/"): + nodeid = nodeid[len("tests/"):] all_matches = find_all_matches(nodeid, conditions, session, dynamic_update_skip_reason, basic_facts) if all_matches: