Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1900,21 +1900,22 @@ def _run_suite(suite):
raise TestFailed(err)


_match_tests = None
_match_test1 = None

def _match_test(test):
global match_tests
global _match_tests, _match_test1

if match_tests is None:
return True
if match_tests != _match_tests:
match_tests_re = '|'.join(map(fnmatch.translate, match_tests))
_match_test1 = re.compile(match_tests_re).match
_match_tests = match_tests[:]
test_id = test.id()

for match_test in match_tests:
if fnmatch.fnmatchcase(test_id, match_test):
return True

for name in test_id.split("."):
if fnmatch.fnmatchcase(name, match_test):
return True
return False
if _match_test1(test_id):
return True
return any(map(_match_test1, test_id.split(".")))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If all match_tests patterns contain a dot ".", we could make this code even simpler:

return match_test(test_id)

But I'm unable to see a major performance difference when running:

./python -m test.bisect --fail-env-changed -o bisect test_asyncio -v

I'm checking how much time it takes before running the first test: so the time to load and filter tests.



def run_unittest(*classes):
Expand Down