From cb0170bd213a6c83a5ece7ec1cd137ee66c5fc07 Mon Sep 17 00:00:00 2001 From: Shweta Singh Date: Thu, 30 May 2024 16:34:11 +0530 Subject: [PATCH] Add marker for case insensitive test collection by component and importance (#15005) Collect tests with case insensitive component marker (cherry picked from commit 3fa1539607ed28a7362bcf30359bafcb4c537411) --- pytest_plugins/metadata_markers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pytest_plugins/metadata_markers.py b/pytest_plugins/metadata_markers.py index 59b1e6c9e56..1e04182279d 100644 --- a/pytest_plugins/metadata_markers.py +++ b/pytest_plugins/metadata_markers.py @@ -163,8 +163,8 @@ def pytest_collection_modifyitems(items, config): # split the option string and handle no option, single option, multiple # config.getoption(default) doesn't work like you think it does, hence or '' - importance = [i for i in (config.getoption('importance') or '').split(',') if i != ''] - component = [c for c in (config.getoption('component') or '').split(',') if c != ''] + importance = [i.lower() for i in (config.getoption('importance') or '').split(',') if i != ''] + component = [c.lower() for c in (config.getoption('component') or '').split(',') if c != ''] team = [a.lower() for a in (config.getoption('team') or '').split(',') if a != ''] verifies_issues = config.getoption('verifies_issues') blocked_by = config.getoption('blocked_by') @@ -192,10 +192,10 @@ def pytest_collection_modifyitems(items, config): # only add the mark if it hasn't already been applied at a lower scope doc_component = component_regex.findall(docstring) if doc_component and 'component' not in item_mark_names: - item.add_marker(pytest.mark.component(doc_component[0])) + item.add_marker(pytest.mark.component(doc_component[0].lower())) doc_importance = importance_regex.findall(docstring) if doc_importance and 'importance' not in item_mark_names: - item.add_marker(pytest.mark.importance(doc_importance[0])) + item.add_marker(pytest.mark.importance(doc_importance[0].lower())) doc_team = team_regex.findall(docstring) if doc_team and 'team' not in item_mark_names: item.add_marker(pytest.mark.team(doc_team[0].lower()))