From 29b7efa36bd12234a4086cafbe9b8a4099991d08 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Fri, 26 Aug 2011 11:59:52 +0100 Subject: [PATCH] Improved the logic in which tests are found --- run-tests.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/run-tests.py b/run-tests.py index 96db7f9a..176094b6 100644 --- a/run-tests.py +++ b/run-tests.py @@ -37,21 +37,21 @@ class BetterLoader(TestLoader): if testname[len(common_prefix):] == name: return testcase - all_results = [] + all_tests = [] for testcase, testname in find_all_tests_with_name(): - if testname.endswith('.' + name): - all_results.append((testcase, testname)) - - if len(all_results) == 1: - return all_results[0][0] - elif not len(all_results): - error = 'could not find testcase "%s"' % name - else: - error = 'Too many matches: for "%s"\n%s' % \ - (name, '\n'.join(' - ' + n for c, n in all_results)) - - print >> sys.stderr, 'Error: %s' % error - sys.exit(1) + if testname.endswith('.' + name) or ('.' + name + '.') in testname: + all_tests.append(testcase) + + if not all_tests: + print >> sys.stderr, 'Error: could not find test case for "%s"' % name + sys.exit(1) + + if len(all_tests) == 1: + return all_tests[0] + rv = unittest.TestSuite() + for test in all_tests: + rv.addTest(test) + return rv unittest.main(testLoader=BetterLoader(), defaultTest='suite')