Skip to content

Commit 102e556

Browse files
ruodilLarryXFly
authored andcommitted
[None][test] cherry-pick: add test-model-suites in integration conftest.py (NVIDIA#8388)
Signed-off-by: Ruodi Lu <[email protected]> Co-authored-by: Ruodi Lu <[email protected]> Co-authored-by: Larry <[email protected]> Signed-off-by: Mike Iovine <[email protected]>
1 parent 2225745 commit 102e556

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

tests/integration/defs/conftest.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2318,6 +2318,55 @@ def deselect_by_test_model_suites(test_model_suites, items, test_prefix,
23182318
items[:] = selected
23192319

23202320

2321+
def deselect_by_test_model_suites(test_model_suites, items, test_prefix,
2322+
config):
2323+
"""Filter tests based on the test model suites specified.
2324+
If a test matches any of the test model suite names, it is considered selected.
2325+
2326+
Args:
2327+
test_model_suites: String containing test model suite names separated by semicolons
2328+
items: List of pytest items to filter
2329+
test_prefix: Test prefix if any
2330+
config: Pytest config object
2331+
"""
2332+
if not test_model_suites:
2333+
return
2334+
2335+
# Split by semicolon or space and strip whitespace
2336+
suite_names = [
2337+
suite.strip() for suite in test_model_suites.replace(';', ' ').split()
2338+
if suite.strip()
2339+
]
2340+
2341+
if not suite_names:
2342+
return
2343+
2344+
selected = []
2345+
deselected = []
2346+
2347+
for item in items:
2348+
# Get the test name without prefix for comparison
2349+
test_name = item.nodeid
2350+
if test_prefix and test_name.startswith(f"{test_prefix}/"):
2351+
test_name = test_name[len(f"{test_prefix}/"):]
2352+
2353+
# Check if any suite name matches the test name
2354+
found = False
2355+
for suite_name in suite_names:
2356+
if suite_name in test_name or test_name.endswith(suite_name):
2357+
found = True
2358+
break
2359+
2360+
if found:
2361+
selected.append(item)
2362+
else:
2363+
deselected.append(item)
2364+
2365+
if deselected:
2366+
config.hook.pytest_deselected(items=deselected)
2367+
items[:] = selected
2368+
2369+
23212370
def deselect_by_regex(regexp, items, test_prefix, config):
23222371
"""Filter out tests based on the patterns specified in the given list of regular expressions.
23232372
If a test matches *any* of the expressions in the list it is considered selected."""

0 commit comments

Comments
 (0)