Skip to content

Commit

Permalink
Update the conditional mark skip logic to support regex (#15977)
Browse files Browse the repository at this point in the history
- What is the motivation for this PR?
Update the conditional mark skip logic to support regular expression

- How did you do it?
Please see the summary

- How did you verify/test it?
Run regression with this change and skipped conditions with the regex key, no issues observed.
  • Loading branch information
congh-nvidia authored Dec 19, 2024
1 parent 4e64fd8 commit 86a132e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/common/plugins/conditional_mark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,18 @@ def find_all_matches(nodeid, conditions):

for condition in conditions:
# condition is a dict which has only one item, so we use condition.keys()[0] to get its key.
if nodeid.startswith(list(condition.keys())[0]):
condition_entry = list(condition.keys())[0]
condition_items = condition[condition_entry]
if "regex" in condition_items.keys():
assert isinstance(condition_items["regex"], bool), \
"The value of 'regex' in the mark conditions yaml should be bool type."
if condition_items["regex"] is True:
match = re.search(condition_entry, nodeid)
else:
match = None
else:
match = nodeid.startswith(condition_entry)
if match:
all_matches.append(condition)

for match in all_matches:
Expand Down Expand Up @@ -616,6 +627,8 @@ def pytest_collection_modifyitems(session, config, items):
for match in all_matches:
# match is a dict which has only one item, so we use match.values()[0] to get its value.
for mark_name, mark_details in list(list(match.values())[0].items()):
if mark_name == "regex":
continue
conditions_logical_operator = mark_details.get('conditions_logical_operator', 'AND').upper()
add_mark = False
if not mark_details:
Expand Down

0 comments on commit 86a132e

Please sign in to comment.