bpo-30523: regrtest --list-cases --match (#2401)
* regrtest --list-cases now supports --match and --match-file options.
Example: ./python -m test --list-cases -m FileTests test_os
* --list-cases now also sets support.verbose to False to prevent
messages to stdout when loading test modules.
* Add support._match_test() private function.
diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py
index 527de17..1a77655 100644
--- a/Lib/test/libregrtest/main.py
+++ b/Lib/test/libregrtest/main.py
@@ -256,9 +256,13 @@
if isinstance(test, unittest.TestSuite):
self._list_cases(test)
elif isinstance(test, unittest.TestCase):
- print(test.id())
+ if support._match_test(test):
+ print(test.id())
def list_cases(self):
+ support.verbose = False
+ support.match_tests = self.ns.match_tests
+
for test in self.selected:
abstest = get_abs_module(self.ns, test)
try: