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:
Chris Jerdonek 2021-03-29 00:21:20 -07:00 committed by GitHub
parent ed0cc52dc3
commit 61d5e57353
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -858,8 +858,9 @@ def test_match_tags(test, tags, exclude_tags):
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)
if tags and test_tags.isdisjoint(tags):
return False
return test_tags.isdisjoint(exclude_tags)
def filter_tests_by_tags(tests, tags, exclude_tags):