mirror of
https://github.com/django/django.git
synced 2025-04-01 12:06:43 +00:00
Refs #32489 -- Simplified filter_tests_by_tags().
This commit is contained in:
parent
8ff75a3d9e
commit
465fdffda0
@ -800,18 +800,20 @@ def partition_suite_by_case(suite):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test_match_tags(test, tags, exclude_tags):
|
||||||
|
test_tags = set(getattr(test, 'tags', []))
|
||||||
|
test_fn_name = getattr(test, '_testMethodName', str(test))
|
||||||
|
if hasattr(test, test_fn_name):
|
||||||
|
test_fn = getattr(test, test_fn_name)
|
||||||
|
test_fn_tags = list(getattr(test_fn, 'tags', []))
|
||||||
|
test_tags = test_tags.union(test_fn_tags)
|
||||||
|
matched_tags = test_tags.intersection(tags)
|
||||||
|
return (matched_tags or not tags) and not test_tags.intersection(exclude_tags)
|
||||||
|
|
||||||
|
|
||||||
def filter_tests_by_tags(suite, tags, exclude_tags):
|
def filter_tests_by_tags(suite, tags, exclude_tags):
|
||||||
suite_class = type(suite)
|
suite_class = type(suite)
|
||||||
filtered_suite = suite_class()
|
return suite_class(
|
||||||
|
test for test in iter_test_cases(suite)
|
||||||
for test in iter_test_cases(suite):
|
if test_match_tags(test, tags, exclude_tags)
|
||||||
test_tags = set(getattr(test, 'tags', set()))
|
)
|
||||||
test_fn_name = getattr(test, '_testMethodName', str(test))
|
|
||||||
test_fn = getattr(test, test_fn_name, test)
|
|
||||||
test_fn_tags = set(getattr(test_fn, 'tags', set()))
|
|
||||||
all_tags = test_tags.union(test_fn_tags)
|
|
||||||
matched_tags = all_tags.intersection(tags)
|
|
||||||
if (matched_tags or not tags) and not all_tags.intersection(exclude_tags):
|
|
||||||
filtered_suite.addTest(test)
|
|
||||||
|
|
||||||
return filtered_suite
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user