summaryrefslogtreecommitdiffstats
path: root/Lib/test/support/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/support/__init__.py')
-rw-r--r--Lib/test/support/__init__.py32
1 files changed, 18 insertions, 14 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index 0a3d4d9..817ba67 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -1905,6 +1905,23 @@ def _run_suite(suite):
raise TestFailed(err)
+def _match_test(test):
+ global match_tests
+
+ if match_tests is None:
+ return True
+ 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
+
+
def run_unittest(*classes):
"""Run tests from unittest.TestCase-derived classes."""
valid_types = (unittest.TestSuite, unittest.TestCase)
@@ -1919,20 +1936,7 @@ def run_unittest(*classes):
suite.addTest(cls)
else:
suite.addTest(unittest.makeSuite(cls))
- def case_pred(test):
- if match_tests is None:
- return True
- 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
- _filter_suite(suite, case_pred)
+ _filter_suite(suite, _match_test)
_run_suite(suite)
#=======================================================================