summaryrefslogtreecommitdiff
path: root/django/test/runner.py
diff options
context:
space:
mode:
authorChris Jerdonek <chris.jerdonek@gmail.com>2021-03-29 00:21:20 -0700
committerGitHub <noreply@github.com>2021-03-29 09:21:20 +0200
commit61d5e57353bb811df7b5457a1856baee31299429 (patch)
tree118e828ee89700da13e23ce63505bcdc4dc2a883 /django/test/runner.py
parented0cc52dc3b0dfebba8a38c12b6157a007309900 (diff)
downloaddjango-61d5e57353bb811df7b5457a1856baee31299429.tar.gz
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.
Diffstat (limited to 'django/test/runner.py')
-rw-r--r--django/test/runner.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/django/test/runner.py b/django/test/runner.py
index 6d283bef97..c19e622170 100644
--- a/django/test/runner.py
+++ b/django/test/runner.py
@@ -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):