Simplified and optimized test_match_tags().
This simplifies and optimizes runner.py's test_match_tags() because it (1) uses isdisjoint() instead of intersection(), which involves constructing a new set, (2) eliminates a set operation when tags is falsey, (3) eliminates the need for a matched_tags variable, and (4) uses fewer not's, which should make it easier to parse and understand.
This commit is contained in:
parent
ed0cc52dc3
commit
61d5e57353
|
@ -858,8 +858,9 @@ def test_match_tags(test, tags, exclude_tags):
|
||||||
test_fn = getattr(test, test_fn_name)
|
test_fn = getattr(test, test_fn_name)
|
||||||
test_fn_tags = list(getattr(test_fn, 'tags', []))
|
test_fn_tags = list(getattr(test_fn, 'tags', []))
|
||||||
test_tags = test_tags.union(test_fn_tags)
|
test_tags = test_tags.union(test_fn_tags)
|
||||||
matched_tags = test_tags.intersection(tags)
|
if tags and test_tags.isdisjoint(tags):
|
||||||
return (matched_tags or not tags) and not test_tags.intersection(exclude_tags)
|
return False
|
||||||
|
return test_tags.isdisjoint(exclude_tags)
|
||||||
|
|
||||||
|
|
||||||
def filter_tests_by_tags(tests, tags, exclude_tags):
|
def filter_tests_by_tags(tests, tags, exclude_tags):
|
||||||
|
|
Loading…
Reference in New Issue