bpo-30523: regrtest --list-cases --match (#2401) · python/cpython@ace56d5

@@ -1905,6 +1905,23 @@ def _run_suite(suite):

19051905

raise TestFailed(err)

19061906190719071908+

def _match_test(test):

1909+

global match_tests

1910+1911+

if match_tests is None:

1912+

return True

1913+

test_id = test.id()

1914+1915+

for match_test in match_tests:

1916+

if fnmatch.fnmatchcase(test_id, match_test):

1917+

return True

1918+1919+

for name in test_id.split("."):

1920+

if fnmatch.fnmatchcase(name, match_test):

1921+

return True

1922+

return False

1923+1924+19081925

def run_unittest(*classes):

19091926

"""Run tests from unittest.TestCase-derived classes."""

19101927

valid_types = (unittest.TestSuite, unittest.TestCase)

@@ -1919,20 +1936,7 @@ def run_unittest(*classes):

19191936

suite.addTest(cls)

19201937

else:

19211938

suite.addTest(unittest.makeSuite(cls))

1922-

def case_pred(test):

1923-

if match_tests is None:

1924-

return True

1925-

test_id = test.id()

1926-1927-

for match_test in match_tests:

1928-

if fnmatch.fnmatchcase(test_id, match_test):

1929-

return True

1930-1931-

for name in test_id.split("."):

1932-

if fnmatch.fnmatchcase(name, match_test):

1933-

return True

1934-

return False

1935-

_filter_suite(suite, case_pred)

1939+

_filter_suite(suite, _match_test)

19361940

_run_suite(suite)

1937194119381942

#=======================================================================