Fix handling of shortcuts in db test runner

This commit is contained in:
Kovid Goyal 2013-06-07 16:07:30 +05:30
parent b595198dd2
commit 4d637f7212

View File

@ -24,16 +24,23 @@ if __name__ == '__main__':
args = parser.parse_args() args = parser.parse_args()
if args.name and args.name.startswith('.'): if args.name and args.name.startswith('.'):
tests = find_tests() tests = find_tests()
q = args.name[1:]
if not q.startswith('test_'):
q = 'test_' + q
ans = None ans = None
try: try:
for suite in tests: for suite in tests:
for test in suite._tests: for test in suite._tests:
for s in test: for s in test:
if s._testMethodName == args.name[1:]: if s._testMethodName == q:
tests = s ans = s
raise StopIteration() raise StopIteration()
except StopIteration: except StopIteration:
pass pass
if ans is None:
print ('No test named %s found' % args.name)
raise SystemExit(1)
tests = ans
else: else:
tests = unittest.defaultTestLoader.loadTestsFromName(args.name) if args.name else find_tests() tests = unittest.defaultTestLoader.loadTestsFromName(args.name) if args.name else find_tests()
unittest.TextTestRunner(verbosity=4).run(tests) unittest.TextTestRunner(verbosity=4).run(tests)