Browse Source

Improved the logic in which tests are found

pull/309/head
Armin Ronacher 14 years ago
parent
commit
29b7efa36b
  1. 28
      run-tests.py

28
run-tests.py

@ -37,21 +37,21 @@ class BetterLoader(TestLoader):
if testname[len(common_prefix):] == name: if testname[len(common_prefix):] == name:
return testcase return testcase
all_results = [] all_tests = []
for testcase, testname in find_all_tests_with_name(): for testcase, testname in find_all_tests_with_name():
if testname.endswith('.' + name): if testname.endswith('.' + name) or ('.' + name + '.') in testname:
all_results.append((testcase, testname)) all_tests.append(testcase)
if len(all_results) == 1: if not all_tests:
return all_results[0][0] print >> sys.stderr, 'Error: could not find test case for "%s"' % name
elif not len(all_results): sys.exit(1)
error = 'could not find testcase "%s"' % name
else: if len(all_tests) == 1:
error = 'Too many matches: for "%s"\n%s' % \ return all_tests[0]
(name, '\n'.join(' - ' + n for c, n in all_results)) rv = unittest.TestSuite()
for test in all_tests:
print >> sys.stderr, 'Error: %s' % error rv.addTest(test)
sys.exit(1) return rv
unittest.main(testLoader=BetterLoader(), defaultTest='suite') unittest.main(testLoader=BetterLoader(), defaultTest='suite')

Loading…
Cancel
Save